home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 June: Reference Library / Dev.CD Jun 96 RL / Dev.CD Jun 96 RL.toast / Technical Documentation / develop / develop Issue 11 / develop Issue 11 code / MultiBuffer.sea / MultiBuffer / MultiBuffer Source / AIFFGoodies.c next >
MacBinary  |  1992-07-15  |  15.8 KB  |  [TEXT/MPS ]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
66% dexvert Compact Compressed (Unix) (archive/compact) ext Supported
1% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, inited, Wed Jul 15 15:24:25 1992, modified Wed Jul 15 15:24:25 1992, creator 'MPS ', type ASCII, 15321 bytes "AIFFGoodies.c" , at 0x3c59 632 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% dearkID deark: macbinary default
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[MPS ]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0d 41 49 46 46 47 6f | 6f 64 69 65 73 2e 63 00 |..AIFFGo|odies.c.|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 4d 50 53 | 20 01 00 00 00 00 00 00 |.TEXTMPS| .......|
|00000050| 00 00 00 00 00 3b d9 00 | 00 02 78 a6 8a 2b e9 a6 |.....;..|..x..+..|
|00000060| 8a 2b e9 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |.+......|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 2a aa 00 00 |........|....*...|
|00000080| 2f 2a 0d 2a 2a 09 09 41 | 49 46 46 47 6f 6f 64 69 |/*.**..A|IFFGoodi|
|00000090| 65 73 0d 2a 2a 0d 2a 2a | 09 09 09 54 68 69 73 20 |es.**.**|...This |
|000000a0| 6d 6f 64 75 6c 65 20 63 | 6f 6e 74 61 69 6e 73 20 |module c|ontains |
|000000b0| 74 68 65 20 72 6f 75 74 | 69 6e 65 73 20 74 68 61 |the rout|ines tha|
|000000c0| 74 20 70 65 72 74 69 61 | 6e 20 74 6f 20 6f 70 65 |t pertia|n to ope|
|000000d0| 6e 69 6e 67 2c 20 72 65 | 61 64 69 6e 67 20 61 6e |ning, re|ading an|
|000000e0| 64 20 6f 74 68 65 72 77 | 69 73 65 20 64 65 61 6c |d otherw|ise deal|
|000000f0| 69 6e 67 0d 2a 2a 09 09 | 09 09 77 69 74 68 20 41 |ing.**..|..with A|
|00000100| 49 46 46 20 46 69 6c 65 | 73 0d 2a 2a 0d 2a 2a 09 |IFF File|s.**.**.|
|00000110| 09 09 28 4e 4d 44 29 09 | 39 2f 31 36 2f 39 31 09 |..(NMD).|9/16/91.|
|00000120| 09 63 72 65 61 74 65 64 | 0d 2a 2a 09 09 09 28 4e |.created|.**...(N|
|00000130| 4d 44 29 09 39 2f 31 36 | 2f 39 31 09 09 4f 70 65 |MD).9/16|/91..Ope|
|00000140| 6e 41 49 46 46 46 69 6c | 65 0d 2a 2a 09 09 09 28 |nAIFFFil|e.**...(|
|00000150| 4e 4d 44 29 09 39 2f 31 | 36 2f 39 31 09 09 47 65 |NMD).9/1|6/91..Ge|
|00000160| 74 41 49 46 46 48 65 61 | 64 65 72 49 6e 66 6f 0d |tAIFFHea|derInfo.|
|00000170| 2a 2a 09 09 09 09 09 09 | 09 09 09 a5 20 43 68 61 |**......|.... Cha|
|00000180| 6e 67 65 64 20 74 6f 20 | 74 61 6b 65 20 74 68 65 |nged to |take the|
|00000190| 20 70 61 72 61 6d 42 6c | 6f 63 6b 20 61 73 20 61 | paramBl|ock as a|
|000001a0| 6e 20 61 72 67 75 6d 65 | 6e 74 20 61 6e 64 20 72 |n argume|nt and r|
|000001b0| 65 74 75 72 6e 20 61 20 | 6c 6f 6e 67 0d 2a 2a 09 |eturn a |long.**.|
|000001c0| 09 09 09 09 09 09 09 09 | 09 69 6e 64 69 63 61 74 |........|.indicat|
|000001d0| 69 6e 67 20 74 68 65 20 | 74 6f 74 61 6c 20 6c 65 |ing the |total le|
|000001e0| 6e 67 74 68 20 6f 66 20 | 74 68 65 20 41 49 46 46 |ngth of |the AIFF|
|000001f0| 20 64 61 74 61 2e 0d 2a | 2a 09 09 09 28 4e 4d 44 | data..*|*...(NMD|
|00000200| 29 09 39 2f 32 30 2f 39 | 31 09 09 46 69 78 65 64 |).9/20/9|1..Fixed|
|00000210| 20 47 65 74 41 49 46 46 | 48 65 61 64 65 72 49 6e | GetAIFF|HeaderIn|
|00000220| 66 6f 20 74 6f 20 28 70 | 72 6f 70 65 72 6c 79 29 |fo to (p|roperly)|
|00000230| 20 64 65 61 6c 20 77 69 | 74 68 20 6f 6e 6c 79 20 | deal wi|th only |
|00000240| 38 20 62 69 74 20 6d 6f | 6e 6f 70 68 6f 6e 69 63 |8 bit mo|nophonic|
|00000250| 20 73 61 6d 70 6c 65 73 | 2e 0d 2a 2a 09 09 09 28 | samples|..**...(|
|00000260| 4e 4d 44 29 09 31 30 2f | 33 2f 39 31 09 09 43 68 |NMD).10/|3/91..Ch|
|00000270| 61 6e 67 65 64 20 47 65 | 74 41 49 46 46 48 65 61 |anged Ge|tAIFFHea|
|00000280| 64 65 72 49 6e 66 6f 20 | 73 6f 20 69 74 20 64 6f |derInfo |so it do|
|00000290| 65 73 6e 27 74 20 73 74 | 6f 6d 70 20 6f 6e 20 74 |esn't st|omp on t|
|000002a0| 68 65 20 73 61 6d 70 6c | 65 50 74 72 20 26 20 6c |he sampl|ePtr & l|
|000002b0| 65 6e 67 68 74 2e 2e 2e | 0d 2a 2a 09 09 09 28 4e |enght...|.**...(N|
|000002c0| 4d 44 29 09 31 31 2f 32 | 39 2f 39 31 09 52 65 63 |MD).11/2|9/91.Rec|
|000002d0| 6f 72 64 41 49 46 46 46 | 69 6c 65 20 20 61 6c 6c |ordAIFFF|ile all|
|000002e0| 6f 77 73 20 79 6f 75 20 | 74 6f 20 72 65 63 6f 72 |ows you |to recor|
|000002f0| 64 20 61 6e 20 61 69 66 | 66 20 66 69 6c 65 20 74 |d an aif|f file t|
|00000300| 6f 20 64 69 73 6b 2e 2e | 2e 0d 2a 2f 0d 0d 0d 23 |o disk..|..*/...#|
|00000310| 70 72 61 67 6d 61 20 6c | 6f 61 64 20 22 4d 61 63 |pragma l|oad "Mac|
|00000320| 48 65 61 64 65 72 73 22 | 0d 0d 23 69 6e 63 6c 75 |Headers"|..#inclu|
|00000330| 64 65 20 3c 46 69 78 4d | 61 74 68 2e 68 3e 0d 0d |de <FixM|ath.h>..|
|00000340| 23 69 66 6e 64 65 66 20 | 5f 5f 4d 41 49 4e 49 4e |#ifndef |__MAININ|
|00000350| 43 4c 55 44 45 53 5f 5f | 0d 23 69 6e 63 6c 75 64 |CLUDES__|.#includ|
|00000360| 65 20 22 4d 61 69 6e 41 | 70 70 2e 68 22 0d 23 65 |e "MainA|pp.h".#e|
|00000370| 6e 64 69 66 0d 0d 0d 23 | 64 65 66 69 6e 65 20 6b |ndif...#|define k|
|00000380| 43 68 75 6e 6b 42 75 66 | 66 65 72 53 69 7a 65 20 |ChunkBuf|ferSize |
|00000390| 09 31 32 38 0d 0d 23 64 | 65 66 69 6e 65 20 6b 43 |.128..#d|efine kC|
|000003a0| 68 75 6e 6b 48 65 61 64 | 65 72 53 69 7a 65 09 38 |hunkHead|erSize.8|
|000003b0| 0d 0d 65 6e 75 6d 20 7b | 09 09 09 09 09 09 09 09 |..enum {|........|
|000003c0| 09 09 09 09 09 09 09 09 | 09 09 09 09 09 09 09 09 |........|........|
|000003d0| 09 09 2f 2f 20 53 61 6d | 70 6c 65 20 73 69 7a 65 |..// Sam|ple size|
|000003e0| 73 0d 09 6b 38 62 69 74 | 73 20 09 09 09 09 09 3d |s..k8bit|s .....=|
|000003f0| 20 38 2c 0d 09 6b 31 36 | 62 69 74 73 20 09 09 09 | 8,..k16|bits ...|
|00000400| 09 3d 20 31 36 2c 0d 09 | 6b 32 34 62 69 74 73 20 |.= 16,..|k24bits |
|00000410| 09 09 09 09 3d 20 32 34 | 2c 0d 09 6b 33 32 62 69 |....= 24|,..k32bi|
|00000420| 74 73 20 09 09 09 09 3d | 20 33 32 0d 7d 3b 0d 0d |ts ....=| 32.};..|
|00000430| 2f 2f 20 74 68 65 73 65 | 20 61 72 65 20 62 69 74 |// these| are bit|
|00000440| 20 70 6f 73 69 74 69 6f | 6e 73 20 66 6f 72 20 61 | positio|ns for a|
|00000450| 20 6c 6f 6e 67 20 66 6c | 61 67 0d 0d 23 64 65 66 | long fl|ag..#def|
|00000460| 69 6e 65 20 6b 46 4f 52 | 4d 09 09 09 09 09 28 31 |ine kFOR|M.....(1|
|00000470| 3c 3c 30 29 0d 23 64 65 | 66 69 6e 65 20 6b 46 6f |<<0).#de|fine kFo|
|00000480| 72 6d 61 74 56 65 72 73 | 69 6f 6e 09 09 09 28 31 |rmatVers|ion...(1|
|00000490| 3c 3c 31 29 0d 23 64 65 | 66 69 6e 65 20 6b 43 6f |<<1).#de|fine kCo|
|000004a0| 6d 6d 6f 6e 09 09 09 09 | 09 28 31 3c 3c 32 29 0d |mmon....|.(1<<2).|
|000004b0| 23 64 65 66 69 6e 65 20 | 6b 53 6f 75 6e 64 44 61 |#define |kSoundDa|
|000004c0| 74 61 09 09 09 09 28 31 | 3c 3c 33 29 0d 23 64 65 |ta....(1|<<3).#de|
|000004d0| 66 69 6e 65 20 6b 4d 61 | 72 6b 65 72 09 09 09 09 |fine kMa|rker....|
|000004e0| 09 28 31 3c 3c 34 29 0d | 23 64 65 66 69 6e 65 20 |.(1<<4).|#define |
|000004f0| 6b 49 6e 73 74 72 75 6d | 65 6e 74 09 09 09 09 28 |kInstrum|ent....(|
|00000500| 31 3c 3c 35 29 0d 23 64 | 65 66 69 6e 65 20 6b 4d |1<<5).#d|efine kM|
|00000510| 49 44 49 44 61 74 61 09 | 09 09 09 28 31 3c 3c 36 |IDIData.|...(1<<6|
|00000520| 29 0d 23 64 65 66 69 6e | 65 20 6b 41 75 64 69 6f |).#defin|e kAudio|
|00000530| 52 65 63 6f 72 64 69 6e | 67 09 09 09 28 31 3c 3c |Recordin|g...(1<<|
|00000540| 37 29 0d 23 64 65 66 69 | 6e 65 20 6b 41 70 70 6c |7).#defi|ne kAppl|
|00000550| 69 63 61 74 69 6f 6e 53 | 70 65 63 69 66 69 63 09 |icationS|pecific.|
|00000560| 28 31 3c 3c 38 29 0d 23 | 64 65 66 69 6e 65 20 6b |(1<<8).#|define k|
|00000570| 43 6f 6d 6d 65 6e 74 09 | 09 09 09 28 31 3c 3c 39 |Comment.|...(1<<9|
|00000580| 29 0d 23 64 65 66 69 6e | 65 20 6b 4e 61 6d 65 09 |).#defin|e kName.|
|00000590| 09 09 09 09 28 31 3c 3c | 31 30 29 0d 23 64 65 66 |....(1<<|10).#def|
|000005a0| 69 6e 65 20 6b 41 75 74 | 68 6f 72 09 09 09 09 09 |ine kAut|hor.....|
|000005b0| 28 31 3c 3c 31 32 29 0d | 23 64 65 66 69 6e 65 20 |(1<<12).|#define |
|000005c0| 6b 43 6f 70 79 72 69 67 | 68 74 09 09 09 09 28 31 |kCopyrig|ht....(1|
|000005d0| 3c 3c 31 33 29 0d 23 64 | 65 66 69 6e 65 20 6b 41 |<<13).#d|efine kA|
|000005e0| 6e 6e 6f 74 61 74 69 6f | 6e 09 09 09 09 28 31 3c |nnotatio|n....(1<|
|000005f0| 3c 31 34 29 0d 0d 0d 74 | 79 70 65 64 65 66 20 75 |<14)...t|ypedef u|
|00000600| 6e 69 6f 6e 20 7b 0d 09 | 43 68 75 6e 6b 48 65 61 |nion {..|ChunkHea|
|00000610| 64 65 72 09 09 09 09 09 | 67 65 6e 65 72 69 63 3b |der.....|generic;|
|00000620| 0d 09 43 6f 6e 74 61 69 | 6e 65 72 43 68 75 6e 6b |..Contai|nerChunk|
|00000630| 09 09 09 09 63 6f 6e 74 | 61 69 6e 65 72 3b 0d 09 |....cont|ainer;..|
|00000640| 46 6f 72 6d 61 74 56 65 | 72 73 69 6f 6e 43 68 75 |FormatVe|rsionChu|
|00000650| 6e 6b 09 09 09 66 6f 72 | 6d 61 74 56 65 72 73 69 |nk...for|matVersi|
|00000660| 6f 6e 3b 0d 09 43 6f 6d | 6d 6f 6e 43 68 75 6e 6b |on;..Com|monChunk|
|00000670| 09 09 09 09 09 63 6f 6d | 6d 6f 6e 3b 0d 09 45 78 |.....com|mon;..Ex|
|00000680| 74 43 6f 6d 6d 6f 6e 43 | 68 75 6e 6b 09 09 09 09 |tCommonC|hunk....|
|00000690| 65 78 74 43 6f 6d 6d 6f | 6e 3b 0d 09 53 6f 75 6e |extCommo|n;..Soun|
|000006a0| 64 44 61 74 61 43 68 75 | 6e 6b 09 09 09 09 73 6f |dDataChu|nk....so|
|000006b0| 75 6e 64 44 61 74 61 3b | 0d 09 4d 61 72 6b 65 72 |undData;|..Marker|
|000006c0| 43 68 75 6e 6b 09 09 09 | 09 09 6d 61 72 6b 65 72 |Chunk...|..marker|
|000006d0| 3b 0d 09 49 6e 73 74 72 | 75 6d 65 6e 74 43 68 75 |;..Instr|umentChu|
|000006e0| 6e 6b 09 09 09 09 69 6e | 73 74 72 75 6d 65 6e 74 |nk....in|strument|
|000006f0| 3b 0d 09 4d 49 44 49 44 | 61 74 61 43 68 75 6e 6b |;..MIDID|ataChunk|
|00000700| 09 09 09 09 6d 69 64 69 | 44 61 74 61 3b 0d 09 41 |....midi|Data;..A|
|00000710| 75 64 69 6f 52 65 63 6f | 72 64 69 6e 67 43 68 75 |udioReco|rdingChu|
|00000720| 6e 6b 09 09 09 61 75 64 | 69 6f 52 65 63 6f 72 64 |nk...aud|ioRecord|
|00000730| 69 6e 67 3b 0d 09 43 6f | 6d 6d 65 6e 74 73 43 68 |ing;..Co|mmentsCh|
|00000740| 75 6e 6b 09 09 09 09 63 | 6f 6d 6d 65 6e 74 73 3b |unk....c|omments;|
|00000750| 0d 09 54 65 78 74 43 68 | 75 6e 6b 09 09 09 09 09 |..TextCh|unk.....|
|00000760| 74 65 78 74 3b 0d 7d 20 | 43 68 75 6e 6b 54 65 6d |text;.} |ChunkTem|
|00000770| 70 6c 61 74 65 2c 20 2a | 43 68 75 6e 6b 54 65 6d |plate, *|ChunkTem|
|00000780| 70 6c 61 74 65 50 74 72 | 3b 0d 0d 0d 2f 2f 0d 2f |platePtr|;...//./|
|00000790| 2f 09 09 47 69 76 65 6e | 20 61 6e 20 41 49 46 46 |/..Given| an AIFF|
|000007a0| 20 46 69 6c 65 20 67 65 | 74 73 20 74 68 65 20 73 | File ge|ts the s|
|000007b0| 61 6d 70 6c 65 20 72 61 | 74 65 20 61 6e 64 20 6f |ample ra|te and o|
|000007c0| 74 68 65 72 20 72 65 6c | 61 76 65 6e 74 20 70 69 |ther rel|avent pi|
|000007d0| 65 63 65 73 20 6f 66 20 | 69 6e 66 6f 72 6d 61 74 |eces of |informat|
|000007e0| 69 6f 6e 2e 0d 2f 2f 09 | 09 09 4c 65 61 76 65 73 |ion..//.|..Leaves|
|000007f0| 20 74 68 65 20 66 69 6c | 65 20 6d 61 72 6b 20 61 | the fil|e mark a|
|00000800| 74 20 74 68 65 20 62 65 | 67 69 6e 6e 69 6e 67 20 |t the be|ginning |
|00000810| 6f 66 20 74 68 65 20 41 | 49 46 46 20 53 6f 75 6e |of the A|IFF Soun|
|00000820| 64 20 44 61 74 61 20 43 | 68 75 6e 6b 2e 20 20 50 |d Data C|hunk. P|
|00000830| 6c 65 61 73 65 20 6e 6f | 74 65 0d 2f 2f 09 09 09 |lease no|te.//...|
|00000840| 74 68 61 74 20 49 27 6d | 20 70 6c 61 63 69 6e 67 |that I'm| placing|
|00000850| 20 73 6f 6d 65 20 70 72 | 65 74 74 79 20 73 65 76 | some pr|etty sev|
|00000860| 65 72 65 20 72 65 73 74 | 72 69 63 74 69 6f 6e 73 |ere rest|rictions|
|00000870| 20 6f 6e 20 74 68 65 20 | 74 79 70 65 73 20 6f 66 | on the |types of|
|00000880| 20 73 61 6d 70 6c 65 73 | 20 74 68 61 74 20 74 68 | samples| that th|
|00000890| 69 73 0d 2f 2f 09 09 09 | 77 69 6c 6c 20 61 63 74 |is.//...|will act|
|000008a0| 75 61 6c 6c 79 20 64 65 | 61 6c 20 77 69 74 68 20 |ually de|al with |
|000008b0| 2d 20 38 20 62 69 74 20 | 6d 6f 6e 6f 70 68 6f 6e |- 8 bit |monophon|
|000008c0| 69 63 2c 20 74 6f 20 62 | 65 20 6d 6f 72 65 20 73 |ic, to b|e more s|
|000008d0| 70 65 63 69 66 69 63 2e | 2e 2e 0d 2f 2f 0d 6c 6f |pecific.|...//.lo|
|000008e0| 6e 67 20 47 65 74 41 49 | 46 46 48 65 61 64 65 72 |ng GetAI|FFHeader|
|000008f0| 49 6e 66 6f 20 28 73 68 | 6f 72 74 20 66 72 65 66 |Info (sh|ort fref|
|00000900| 4e 75 6d 2c 20 53 6f 75 | 6e 64 48 65 61 64 65 72 |Num, Sou|ndHeader|
|00000910| 50 74 72 20 74 68 65 48 | 65 61 64 65 72 29 0d 7b |Ptr theH|eader).{|
|00000920| 0d 09 4f 53 45 72 72 09 | 09 09 09 09 65 72 72 3b |..OSErr.|....err;|
|00000930| 09 09 09 09 09 09 09 2f | 2f 20 65 72 72 6f 72 20 |......./|/ error |
|00000940| 63 6f 6e 74 61 69 6e 65 | 72 0d 09 6c 6f 6e 67 09 |containe|r..long.|
|00000950| 09 09 09 09 66 69 6c 65 | 50 6f 73 69 74 69 6f 6e |....file|Position|
|00000960| 3b 09 09 09 09 09 2f 2f | 20 63 75 72 72 65 6e 74 |;.....//| current|
|00000970| 20 70 6f 73 69 74 69 6f | 6e 20 69 6e 20 66 69 6c | positio|n in fil|
|00000980| 65 0d 09 6c 6f 6e 67 09 | 09 09 09 09 64 61 74 61 |e..long.|....data|
|00000990| 53 74 61 72 74 20 3d 20 | 30 3b 09 09 09 09 09 2f |Start = |0;...../|
|000009a0| 2f 20 77 68 65 72 65 20 | 73 6e 64 20 64 61 74 61 |/ where |snd data|
|000009b0| 20 73 74 61 72 74 73 0d | 09 6c 6f 6e 67 09 09 09 | starts.|.long...|
|000009c0| 09 09 64 61 74 61 53 69 | 7a 65 20 3d 20 30 3b 09 |..dataSi|ze = 0;.|
|000009d0| 09 09 09 09 2f 2f 20 68 | 6f 77 20 62 69 67 20 73 |....// h|ow big s|
|000009e0| 6e 64 20 64 61 74 61 20 | 69 73 0d 0d 09 6c 6f 6e |nd data |is...lon|
|000009f0| 67 09 09 09 09 09 62 79 | 74 65 43 6f 75 6e 74 3b |g.....by|teCount;|
|00000a00| 09 09 09 09 09 09 2f 2f | 20 23 20 69 66 20 62 79 |......//| # if by|
|00000a10| 74 65 73 20 74 6f 20 67 | 65 74 20 66 72 6f 6d 20 |tes to g|et from |
|00000a20| 66 69 6c 65 0d 09 63 68 | 61 72 09 09 09 09 09 63 |file..ch|ar.....c|
|00000a30| 68 75 6e 6b 42 75 66 66 | 65 72 5b 6b 43 68 75 6e |hunkBuff|er[kChun|
|00000a40| 6b 42 75 66 66 65 72 53 | 69 7a 65 5d 3b 09 2f 2f |kBufferS|ize];.//|
|00000a50| 20 62 75 66 66 65 72 20 | 66 6f 72 20 63 68 75 6e | buffer |for chun|
|00000a60| 6b 20 64 61 74 61 0d 0d | 09 75 6e 73 69 67 6e 65 |k data..|.unsigne|
|00000a70| 64 20 73 68 6f 72 74 09 | 09 09 63 68 75 6e 6b 46 |d short.|..chunkF|
|00000a80| 6c 61 67 73 20 3d 20 30 | 3b 09 09 09 09 09 2f 2f |lags = 0|;.....//|
|00000a90| 20 72 65 6d 65 6d 62 65 | 72 20 63 68 75 6e 6b 73 | remembe|r chunks|
|00000aa0| 20 77 65 27 76 65 20 73 | 65 65 6e 0d 09 43 68 75 | we've s|een..Chu|
|00000ab0| 6e 6b 54 65 6d 70 6c 61 | 74 65 50 74 72 09 09 74 |nkTempla|tePtr..t|
|00000ac0| 65 6d 70 6c 61 74 65 3b | 09 09 09 09 09 09 2f 2f |emplate;|......//|
|00000ad0| 20 2e 2e 2e 66 6f 72 20 | 65 61 73 65 20 6f 66 20 | ...for |ease of |
|00000ae0| 61 63 63 65 73 73 0d 0d | 09 2f 2f 09 4b 65 65 70 |access..|.//.Keep|
|00000af0| 20 74 72 61 63 6b 20 6f | 66 20 74 68 65 20 62 65 | track o|f the be|
|00000b00| 67 69 6e 6e 69 6e 67 20 | 6f 66 20 74 68 65 20 66 |ginning |of the f|
|00000b10| 69 6c 65 0d 09 65 72 72 | 20 3d 20 47 65 74 46 50 |ile..err| = GetFP|
|00000b20| 6f 73 20 28 66 72 65 66 | 4e 75 6d 2c 20 26 66 69 |os (fref|Num, &fi|
|00000b30| 6c 65 50 6f 73 69 74 69 | 6f 6e 29 3b 0d 09 41 73 |lePositi|on);..As|
|00000b40| 73 65 72 74 20 28 28 65 | 72 72 20 21 3d 20 6e 6f |sert ((e|rr != no|
|00000b50| 45 72 72 29 2c 20 22 5c | 70 43 6f 75 6c 64 6e 27 |Err), "\|pCouldn'|
|00000b60| 74 20 67 65 74 20 66 69 | 6c 65 20 70 6f 73 69 74 |t get fi|le posit|
|00000b70| 69 6f 6e 22 29 3b 0d 0d | 09 2f 2f 20 20 4e 6f 77 |ion");..|.// Now|
|00000b80| 20 66 6f 72 20 74 68 65 | 20 66 75 6e 20 70 61 72 | for the| fun par|
|00000b90| 74 20 21 20 57 65 27 72 | 65 20 67 6f 69 6e 67 20 |t ! We'r|e going |
|00000ba0| 74 6f 20 61 73 73 75 6d | 65 20 74 68 61 74 20 74 |to assum|e that t|
|00000bb0| 68 65 73 65 20 61 72 65 | 20 67 65 6e 65 72 69 63 |hese are| generic|
|00000bc0| 2c 20 6e 6f 6e 2d 63 6f | 6d 70 72 65 73 73 65 64 |, non-co|mpressed|
|00000bd0| 0d 09 2f 2f 09 09 41 49 | 46 46 20 66 69 6c 65 73 |..//..AI|FF files|
|00000be0| 20 61 6e 64 20 70 61 72 | 73 65 20 61 63 63 6f 72 | and par|se accor|
|00000bf0| 64 69 6e 67 6c 79 2e 2e | 2e 0d 0d 09 64 6f 20 7b |dingly..|....do {|
|00000c00| 0d 0d 09 09 2f 2f 09 50 | 6f 73 69 74 69 6f 6e 20 |....//.P|osition |
|00000c10| 6f 75 72 73 65 6c 76 65 | 73 20 61 74 20 74 68 65 |ourselve|s at the|
|00000c20| 20 62 65 67 69 6e 6e 69 | 6e 67 20 6f 66 20 74 68 | beginni|ng of th|
|00000c30| 65 20 6e 65 78 74 20 63 | 68 75 6e 6b 20 61 6e 64 |e next c|hunk and|
|00000c40| 20 72 65 61 64 20 69 6e | 0d 09 09 2f 2f 09 61 20 | read in|...//.a |
|00000c50| 68 75 6e 6b 2d 6f 2d 64 | 61 74 61 2e 2e 2e 0d 09 |hunk-o-d|ata.....|
|00000c60| 09 65 72 72 20 3d 20 53 | 65 74 46 50 6f 73 20 28 |.err = S|etFPos (|
|00000c70| 66 72 65 66 4e 75 6d 2c | 20 66 73 46 72 6f 6d 53 |frefNum,| fsFromS|
|00000c80| 74 61 72 74 2c 20 66 69 | 6c 65 50 6f 73 69 74 69 |tart, fi|lePositi|
|00000c90| 6f 6e 29 3b 0d 09 09 41 | 73 73 65 72 74 20 28 28 |on);...A|ssert ((|
|00000ca0| 65 72 72 20 21 3d 20 6e | 6f 45 72 72 29 2c 20 22 |err != n|oErr), "|
|00000cb0| 5c 70 43 6f 75 6c 64 6e | 27 74 20 73 65 74 20 66 |\pCouldn|'t set f|
|00000cc0| 69 6c 65 20 70 6f 73 69 | 74 69 6f 6e 22 29 3b 0d |ile posi|tion");.|
|00000cd0| 09 09 69 66 20 28 65 72 | 72 20 21 3d 20 6e 6f 45 |..if (er|r != noE|
|00000ce0| 72 72 29 0d 09 09 09 62 | 72 65 61 6b 3b 0d 0d 09 |rr)....b|reak;...|
|00000cf0| 09 62 79 74 65 43 6f 75 | 6e 74 20 3d 20 6b 43 68 |.byteCou|nt = kCh|
|00000d00| 75 6e 6b 42 75 66 66 65 | 72 53 69 7a 65 3b 0d 09 |unkBuffe|rSize;..|
|00000d10| 09 65 72 72 20 3d 20 46 | 53 52 65 61 64 20 28 66 |.err = F|SRead (f|
|00000d20| 72 65 66 4e 75 6d 2c 20 | 26 62 79 74 65 43 6f 75 |refNum, |&byteCou|
|00000d30| 6e 74 2c 20 63 68 75 6e | 6b 42 75 66 66 65 72 29 |nt, chun|kBuffer)|
|00000d40| 3b 09 09 09 09 09 09 09 | 09 09 09 09 09 09 09 2f |;.......|......./|
|00000d50| 2f 20 72 65 61 64 20 61 | 20 63 68 75 6e 6b 0d 09 |/ read a| chunk..|
|00000d60| 09 41 73 73 65 72 74 20 | 28 28 65 72 72 20 21 3d |.Assert |((err !=|
|00000d70| 20 6e 6f 45 72 72 20 26 | 26 20 65 72 72 20 21 3d | noErr &|& err !=|
|00000d80| 20 65 6f 66 45 72 72 29 | 2c 20 22 5c 70 42 6f 6d | eofErr)|, "\pBom|
|00000d90| 62 65 64 20 6f 75 74 20 | 72 65 61 64 69 6e 67 20 |bed out |reading |
|00000da0| 66 69 6c 65 22 29 3b 0d | 09 09 69 66 20 28 20 28 |file");.|..if ( (|
|00000db0| 65 72 72 20 21 3d 20 6e | 6f 45 72 72 29 20 26 26 |err != n|oErr) &&|
|00000dc0| 20 28 65 72 72 20 21 3d | 20 65 6f 66 45 72 72 29 | (err !=| eofErr)|
|00000dd0| 20 29 0d 09 09 09 62 72 | 65 61 6b 3b 0d 0d 09 09 | )....br|eak;....|
|00000de0| 2f 2f 09 4e 6f 77 2c 20 | 70 6f 73 69 74 69 6f 6e |//.Now, |position|
|00000df0| 20 74 68 65 20 74 65 6d | 70 6c 61 74 65 20 6f 76 | the tem|plate ov|
|00000e00| 65 72 20 74 68 65 20 64 | 61 74 61 2e 2e 2e 0d 09 |er the d|ata.....|
|00000e10| 09 74 65 6d 70 6c 61 74 | 65 20 3d 20 28 43 68 75 |.templat|e = (Chu|
|00000e20| 6e 6b 54 65 6d 70 6c 61 | 74 65 50 74 72 29 20 63 |nkTempla|tePtr) c|
|00000e30| 68 75 6e 6b 42 75 66 66 | 65 72 3b 0d 0d 09 09 2f |hunkBuff|er;..../|
|00000e40| 2f 20 61 73 73 75 6d 65 | 20 61 20 66 61 69 6c 75 |/ assume| a failu|
|00000e50| 72 65 20 61 6e 64 20 62 | 72 65 61 6b 20 6f 75 74 |re and b|reak out|
|00000e60| 20 6f 66 20 74 68 65 20 | 64 6f 20 7b 7d 20 77 68 | of the |do {} wh|
|00000e70| 69 6c 65 20 6c 6f 6f 70 | 20 69 66 20 74 68 65 20 |ile loop| if the |
|00000e80| 6e 65 78 74 20 63 61 73 | 65 20 69 73 6e 27 74 20 |next cas|e isn't |
|00000e90| 66 6f 75 6e 64 2e 0d 09 | 09 2f 2f 20 69 66 20 74 |found...|.// if t|
|00000ea0| 68 65 20 63 61 73 65 20 | 69 73 20 66 6f 75 6e 64 |he case |is found|
|00000eb0| 20 61 6e 64 20 6e 6f 20 | 6f 74 68 65 72 20 65 72 | and no |other er|
|00000ec0| 72 6f 72 20 69 73 20 64 | 65 74 65 63 74 65 64 2c |ror is d|etected,|
|00000ed0| 20 74 68 65 6e 20 65 61 | 63 68 20 63 61 73 65 20 | then ea|ch case |
|00000ee0| 6e 65 65 64 73 20 74 6f | 20 73 65 74 20 6e 6f 45 |needs to| set noE|
|00000ef0| 72 72 0d 09 09 65 72 72 | 20 3d 20 62 61 64 46 69 |rr...err| = badFi|
|00000f00| 6c 65 46 6f 72 6d 61 74 | 3b 09 09 09 09 09 09 09 |leFormat|;.......|
|00000f10| 09 0d 09 09 73 77 69 74 | 63 68 20 28 74 65 6d 70 |....swit|ch (temp|
|00000f20| 6c 61 74 65 2d 3e 67 65 | 6e 65 72 69 63 2e 63 6b |late->ge|neric.ck|
|00000f30| 49 44 29 20 7b 0d 09 09 | 0d 09 09 09 63 61 73 65 |ID) {...|....case|
|00000f40| 20 46 4f 52 4d 49 44 20 | 3a 09 09 09 09 09 09 09 | FORMID |:.......|
|00000f50| 09 09 09 09 09 09 09 09 | 09 09 09 09 09 2f 2f 20 |........|.....// |
|00000f60| 46 6f 72 6d 61 74 20 56 | 65 72 73 69 6f 6e 20 43 |Format V|ersion C|
|00000f70| 68 75 6e 6b 3f 0d 09 09 | 09 09 44 65 62 75 67 4d |hunk?...|..DebugM|
|00000f80| 65 73 73 61 67 65 20 28 | 22 5c 70 66 6f 75 6e 64 |essage (|"\pfound|
|00000f90| 20 74 68 65 20 66 6f 72 | 6d 20 63 68 75 6e 6b 22 | the for|m chunk"|
|00000fa0| 29 3b 0d 09 09 09 09 41 | 73 73 65 72 74 20 28 28 |);.....A|ssert ((|
|00000fb0| 63 68 75 6e 6b 46 6c 61 | 67 73 20 26 20 6b 46 4f |chunkFla|gs & kFO|
|00000fc0| 52 4d 29 2c 20 22 5c 70 | 4f 48 20 4e 4f 21 21 20 |RM), "\p|OH NO!! |
|00000fd0| 46 6f 75 6e 64 20 61 20 | 64 75 70 6c 69 63 61 74 |Found a |duplicat|
|00000fe0| 65 20 46 4f 52 4d 20 43 | 68 75 6e 6b 21 21 22 29 |e FORM C|hunk!!")|
|00000ff0| 3b 0d 09 09 09 09 41 73 | 73 65 72 74 20 28 28 74 |;.....As|sert ((t|
|00001000| 65 6d 70 6c 61 74 65 2d | 3e 63 6f 6e 74 61 69 6e |emplate-|>contain|
|00001010| 65 72 2e 66 6f 72 6d 54 | 79 70 65 20 21 3d 20 41 |er.formT|ype != A|
|00001020| 49 46 46 49 44 29 2c 20 | 22 5c 70 74 68 69 73 20 |IFFID), |"\pthis |
|00001030| 69 73 6e 27 74 20 61 20 | 6e 6f 6e 2d 63 6f 6d 70 |isn't a |non-comp|
|00001040| 72 65 73 73 65 64 20 41 | 49 46 46 20 66 69 6c 65 |ressed A|IFF file|
|00001050| 22 29 3b 0d 0d 09 09 09 | 09 2f 2f 09 6d 61 6b 65 |");.....|.//.make|
|00001060| 20 73 75 72 65 20 74 68 | 61 74 20 74 68 69 73 20 | sure th|at this |
|00001070| 69 73 20 61 20 73 74 61 | 6e 64 61 72 64 2c 20 6e |is a sta|ndard, n|
|00001080| 6f 6e 63 6f 6d 70 72 65 | 73 73 65 64 20 41 49 46 |oncompre|ssed AIF|
|00001090| 46 20 66 69 6c 65 2e 0d | 09 09 09 09 69 66 20 28 |F file..|....if (|
|000010a0| 20 21 28 63 68 75 6e 6b | 46 6c 61 67 73 20 26 20 | !(chunk|Flags & |
|000010b0| 6b 46 4f 52 4d 29 20 26 | 26 20 28 74 65 6d 70 6c |kFORM) &|& (templ|
|000010c0| 61 74 65 2d 3e 63 6f 6e | 74 61 69 6e 65 72 2e 66 |ate->con|tainer.f|
|000010d0| 6f 72 6d 54 79 70 65 20 | 3d 3d 20 41 49 46 46 49 |ormType |== AIFFI|
|000010e0| 44 29 20 29 20 7b 09 09 | 09 09 09 09 09 09 09 09 |D) ) {..|........|
|000010f0| 09 09 09 09 09 09 2f 2f | 20 20 73 65 65 20 69 66 |......//| see if|
|00001100| 20 74 68 69 73 20 63 68 | 75 6e 6b 20 61 6c 72 65 | this ch|unk alre|
|00001110| 61 64 79 20 65 78 69 73 | 74 73 0d 09 09 09 09 09 |ady exis|ts......|
|00001120| 63 68 75 6e 6b 46 6c 61 | 67 73 20 7c 3d 20 6b 46 |chunkFla|gs |= kF|
|00001130| 4f 52 4d 3b 09 09 09 09 | 09 09 09 09 09 09 09 09 |ORM;....|........|
|00001140| 09 09 09 09 2f 2f 09 09 | 6f 74 68 65 72 77 69 73 |....//..|otherwis|
|00001150| 65 20 6d 61 72 6b 20 69 | 74 20 66 6f 75 6e 64 0d |e mark i|t found.|
|00001160| 2f 2f 09 09 09 09 09 66 | 69 6c 65 50 6f 73 69 74 |//.....f|ilePosit|
|00001170| 69 6f 6e 20 2b 3d 20 74 | 65 6d 70 6c 61 74 65 2d |ion += t|emplate-|
|00001180| 3e 63 6f 6e 74 61 69 6e | 65 72 2e 63 6b 53 69 7a |>contain|er.ckSiz|
|00001190| 65 20 2b 20 6b 43 68 75 | 6e 6b 48 65 61 64 65 72 |e + kChu|nkHeader|
|000011a0| 53 69 7a 65 3b 09 09 09 | 09 09 09 2f 2f 09 09 63 |Size;...|...//..c|
|000011b0| 61 6c 63 75 6c 61 74 65 | 20 6e 65 78 74 20 63 68 |alculate| next ch|
|000011c0| 75 6e 6b 27 73 20 70 6f | 73 69 74 69 6f 6e 0d 09 |unk's po|sition..|
|000011d0| 09 09 09 09 66 69 6c 65 | 50 6f 73 69 74 69 6f 6e |....file|Position|
|000011e0| 20 2b 3d 20 31 32 3b 0d | 09 09 09 09 09 65 72 72 | += 12;.|.....err|
|000011f0| 20 3d 20 6e 6f 45 72 72 | 3b 0d 09 09 09 09 7d 0d | = noErr|;.....}.|
|00001200| 09 09 09 09 62 72 65 61 | 6b 3b 0d 0d 0d 09 09 09 |....brea|k;......|
|00001210| 63 61 73 65 20 46 6f 72 | 6d 61 74 56 65 72 73 69 |case For|matVersi|
|00001220| 6f 6e 49 44 20 3a 09 09 | 09 09 09 09 09 09 09 09 |onID :..|........|
|00001230| 09 09 09 09 09 09 09 09 | 2f 2f 20 46 6f 72 6d 61 |........|// Forma|
|00001240| 74 20 56 65 72 73 69 6f | 6e 20 43 68 75 6e 6b 3f |t Versio|n Chunk?|
|00001250| 0d 09 09 09 09 44 65 62 | 75 67 4d 65 73 73 61 67 |.....Deb|ugMessag|
|00001260| 65 20 28 22 5c 70 66 6f | 75 6e 64 20 74 68 65 20 |e ("\pfo|und the |
|00001270| 63 6f 6e 74 61 69 6e 65 | 72 20 63 68 75 6e 6b 22 |containe|r chunk"|
|00001280| 29 3b 0d 09 09 09 09 41 | 73 73 65 72 74 20 28 28 |);.....A|ssert ((|
|00001290| 63 68 75 6e 6b 46 6c 61 | 67 73 20 26 20 6b 46 6f |chunkFla|gs & kFo|
|000012a0| 72 6d 61 74 56 65 72 73 | 69 6f 6e 29 2c 20 22 5c |rmatVers|ion), "\|
|000012b0| 70 4f 48 20 4e 4f 21 21 | 20 46 6f 75 6e 64 20 61 |pOH NO!!| Found a|
|000012c0| 20 64 75 70 6c 69 63 61 | 74 65 20 66 6f 72 6d 61 | duplica|te forma|
|000012d0| 74 20 76 65 72 73 69 6f | 6e 20 43 68 75 6e 6b 21 |t versio|n Chunk!|
|000012e0| 21 22 29 3b 0d 0d 09 09 | 09 09 69 66 20 28 20 21 |!");....|..if ( !|
|000012f0| 28 63 68 75 6e 6b 46 6c | 61 67 73 20 26 20 6b 46 |(chunkFl|ags & kF|
|00001300| 6f 72 6d 61 74 56 65 72 | 73 69 6f 6e 29 20 29 20 |ormatVer|sion) ) |
|00001310| 7b 09 09 09 09 09 09 09 | 09 09 09 09 09 09 09 2f |{.......|......./|
|00001320| 2f 20 20 73 65 65 20 69 | 66 20 74 68 69 73 20 63 |/ see i|f this c|
|00001330| 68 75 6e 6b 20 61 6c 72 | 65 61 64 79 20 65 78 69 |hunk alr|eady exi|
|00001340| 73 74 73 0d 09 09 09 09 | 09 63 68 75 6e 6b 46 6c |sts.....|.chunkFl|
|00001350| 61 67 73 20 7c 3d 20 6b | 46 6f 72 6d 61 74 56 65 |ags |= k|FormatVe|
|00001360| 72 73 69 6f 6e 3b 09 09 | 09 09 09 09 09 09 09 09 |rsion;..|........|
|00001370| 09 09 09 09 2f 2f 09 09 | 6f 74 68 65 72 77 69 73 |....//..|otherwis|
|00001380| 65 20 6d 61 72 6b 20 69 | 74 20 66 6f 75 6e 64 0d |e mark i|t found.|
|00001390| 09 09 09 09 09 66 69 6c | 65 50 6f 73 69 74 69 6f |.....fil|ePositio|
|000013a0| 6e 20 2b 3d 20 74 65 6d | 70 6c 61 74 65 2d 3e 66 |n += tem|plate->f|
|000013b0| 6f 72 6d 61 74 56 65 72 | 73 69 6f 6e 2e 63 6b 53 |ormatVer|sion.ckS|
|000013c0| 69 7a 65 20 2b 20 6b 43 | 68 75 6e 6b 48 65 61 64 |ize + kC|hunkHead|
|000013d0| 65 72 53 69 7a 65 3b 09 | 09 09 09 09 2f 2f 09 09 |erSize;.|....//..|
|000013e0| 63 61 6c 63 75 6c 61 74 | 65 20 6e 65 78 74 20 63 |calculat|e next c|
|000013f0| 68 75 6e 6b 27 73 20 70 | 6f 73 69 74 69 6f 6e 0d |hunk's p|osition.|
|00001400| 09 09 09 09 09 65 72 72 | 20 3d 20 6e 6f 45 72 72 |.....err| = noErr|
|00001410| 3b 0d 09 09 09 09 7d 0d | 09 09 09 09 62 72 65 61 |;.....}.|....brea|
|00001420| 6b 3b 0d 0d 0d 09 09 09 | 63 61 73 65 20 43 6f 6d |k;......|case Com|
|00001430| 6d 6f 6e 49 44 20 3a 0d | 09 09 09 09 44 65 62 75 |monID :.|....Debu|
|00001440| 67 4d 65 73 73 61 67 65 | 20 28 22 5c 70 66 6f 75 |gMessage| ("\pfou|
|00001450| 6e 64 20 74 68 65 20 63 | 6f 6d 6d 6f 6e 20 63 68 |nd the c|ommon ch|
|00001460| 75 6e 6b 22 29 3b 0d 09 | 09 09 09 41 73 73 65 72 |unk");..|...Asser|
|00001470| 74 20 28 28 63 68 75 6e | 6b 46 6c 61 67 73 20 26 |t ((chun|kFlags &|
|00001480| 20 6b 43 6f 6d 6d 6f 6e | 29 2c 20 22 5c 70 4f 48 | kCommon|), "\pOH|
|00001490| 20 4e 4f 21 21 20 46 6f | 75 6e 64 20 61 20 64 75 | NO!! Fo|und a du|
|000014a0| 70 6c 69 63 61 74 65 20 | 63 6f 6d 6d 6f 6e 20 43 |plicate |common C|
|000014b0| 68 75 6e 6b 21 21 22 29 | 3b 0d 20 09 09 09 09 41 |hunk!!")|;. ....A|
|000014c0| 73 73 65 72 74 20 28 28 | 74 65 6d 70 6c 61 74 65 |ssert ((|template|
|000014d0| 2d 3e 63 6f 6d 6d 6f 6e | 2e 6e 75 6d 43 68 61 6e |->common|.numChan|
|000014e0| 6e 65 6c 73 20 21 3d 20 | 31 29 2c 20 22 5c 70 54 |nels != |1), "\pT|
|000014f0| 6f 6f 20 6d 61 6e 79 20 | 63 68 61 6e 6e 65 6c 73 |oo many |channels|
|00001500| 22 29 3b 0d 09 09 09 09 | 41 73 73 65 72 74 20 28 |");.....|Assert (|
|00001510| 28 74 65 6d 70 6c 61 74 | 65 2d 3e 63 6f 6d 6d 6f |(templat|e->commo|
|00001520| 6e 2e 73 61 6d 70 6c 65 | 53 69 7a 65 20 21 3d 20 |n.sample|Size != |
|00001530| 6b 38 62 69 74 73 29 2c | 20 22 5c 70 57 72 6f 6e |k8bits),| "\pWron|
|00001540| 67 20 73 61 6d 70 6c 65 | 20 73 69 7a 65 22 29 3b |g sample| size");|
|00001550| 0d 0d 09 09 09 09 69 66 | 20 28 20 09 21 28 63 68 |......if| ( .!(ch|
|00001560| 75 6e 6b 46 6c 61 67 73 | 20 26 20 6b 43 6f 6d 6d |unkFlags| & kComm|
|00001570| 6f 6e 29 0d 09 09 09 09 | 09 09 26 26 20 28 74 65 |on).....|..&& (te|
|00001580| 6d 70 6c 61 74 65 2d 3e | 63 6f 6d 6d 6f 6e 2e 6e |mplate->|common.n|
|00001590| 75 6d 43 68 61 6e 6e 65 | 6c 73 20 3d 3d 20 31 29 |umChanne|ls == 1)|
|000015a0| 0d 09 09 09 09 09 09 26 | 26 20 28 74 65 6d 70 6c |.......&|& (templ|
|000015b0| 61 74 65 2d 3e 63 6f 6d | 6d 6f 6e 2e 73 61 6d 70 |ate->com|mon.samp|
|000015c0| 6c 65 53 69 7a 65 20 3d | 3d 20 6b 38 62 69 74 73 |leSize =|= k8bits|
|000015d0| 29 29 20 7b 09 09 09 09 | 09 09 09 09 09 2f 2f 20 |)) {....|.....// |
|000015e0| 20 73 65 65 20 69 66 20 | 74 68 69 73 20 63 68 75 | see if |this chu|
|000015f0| 6e 6b 20 61 6c 72 65 61 | 64 79 20 65 78 69 73 74 |nk alrea|dy exist|
|00001600| 73 0d 09 09 09 09 09 09 | 0d 09 09 09 09 09 63 68 |s.......|......ch|
|00001610| 75 6e 6b 46 6c 61 67 73 | 20 7c 3d 20 6b 43 6f 6d |unkFlags| |= kCom|
|00001620| 6d 6f 6e 3b 09 09 09 09 | 09 09 09 09 09 09 09 09 |mon;....|........|
|00001630| 09 09 09 09 2f 2f 09 09 | 6f 74 68 65 72 77 69 73 |....//..|otherwis|
|00001640| 65 20 6d 61 72 6b 20 69 | 74 20 66 6f 75 6e 64 0d |e mark i|t found.|
|00001650| 09 09 09 09 09 66 69 6c | 65 50 6f 73 69 74 69 6f |.....fil|ePositio|
|00001660| 6e 20 2b 3d 20 74 65 6d | 70 6c 61 74 65 2d 3e 63 |n += tem|plate->c|
|00001670| 6f 6d 6d 6f 6e 2e 63 6b | 53 69 7a 65 20 2b 20 6b |ommon.ck|Size + k|
|00001680| 43 68 75 6e 6b 48 65 61 | 64 65 72 53 69 7a 65 3b |ChunkHea|derSize;|
|00001690| 09 09 09 09 09 09 09 2f | 2f 09 09 63 61 6c 63 75 |......./|/..calcu|
|000016a0| 6c 61 74 65 20 6e 65 78 | 74 20 63 68 75 6e 6b 27 |late nex|t chunk'|
|000016b0| 73 20 70 6f 73 69 74 69 | 6f 6e 0d 0d 09 09 09 09 |s positi|on......|
|000016c0| 09 2f 2f 09 4e 6f 77 20 | 74 68 61 74 20 77 65 20 |.//.Now |that we |
|000016d0| 74 68 65 6f 72 65 74 69 | 63 61 6c 6c 79 20 68 61 |theoreti|cally ha|
|000016e0| 76 65 20 61 6c 6c 20 74 | 68 65 20 72 65 6c 61 76 |ve all t|he relav|
|000016f0| 61 6e 74 20 69 6e 66 6f | 72 6d 61 74 69 6f 6e 2c |ant info|rmation,|
|00001700| 20 70 75 74 20 69 74 20 | 69 6e 74 6f 20 61 20 68 | put it |into a h|
|00001710| 65 61 64 65 72 20 74 68 | 65 20 73 6f 75 6e 64 20 |eader th|e sound |
|00001720| 6d 61 6e 61 67 65 72 0d | 09 09 09 09 09 2f 2f 09 |manager.|.....//.|
|00001730| 63 61 6e 20 64 65 61 6c | 20 77 69 74 68 2e 20 20 |can deal| with. |
|00001740| 4e 6f 74 65 20 74 68 61 | 74 20 77 65 27 72 65 20 |Note tha|t we're |
|00001750| 6e 6f 74 20 72 65 74 75 | 72 6e 69 6e 67 20 74 68 |not retu|rning th|
|00001760| 65 20 6c 65 6e 67 74 68 | 20 6f 66 20 74 68 65 20 |e length| of the |
|00001770| 66 69 6c 65 20 69 6e 20 | 74 68 65 48 65 61 64 65 |file in |theHeade|
|00001780| 72 2d 3e 6c 65 6e 67 74 | 68 2c 20 62 65 63 61 75 |r->lengt|h, becau|
|00001790| 73 65 20 69 74 20 69 73 | 0d 09 09 09 09 09 2f 2f |se it is|......//|
|000017a0| 09 45 58 54 52 45 4d 45 | 4c 59 20 75 6e 6c 69 6b |.EXTREME|LY unlik|
|000017b0| 65 6c 79 20 74 68 61 74 | 20 74 68 65 20 41 49 46 |ely that| the AIF|
|000017c0| 46 20 66 69 6c 65 20 69 | 73 20 73 6d 61 6c 6c 20 |F file i|s small |
|000017d0| 65 6e 6f 75 67 68 20 74 | 6f 20 66 65 65 64 20 74 |enough t|o feed t|
|000017e0| 68 65 20 53 4d 20 77 69 | 74 68 6f 75 74 20 72 65 |he SM wi|thout re|
|000017f0| 73 6f 72 74 69 6e 67 20 | 74 6f 20 6d 75 6c 74 69 |sorting |to multi|
|00001800| 70 6c 65 20 62 75 66 66 | 65 72 73 2e 0d 09 09 09 |ple buff|ers.....|
|00001810| 09 09 2f 2f 09 20 20 20 | a5 20 4e 6f 74 65 20 74 |..//. |. Note t|
|00001820| 68 61 74 20 77 65 27 72 | 65 20 6e 6f 74 20 6d 6f |hat we'r|e not mo|
|00001830| 64 69 66 79 69 6e 67 20 | 74 68 65 20 68 65 61 64 |difying |the head|
|00001840| 65 72 27 73 20 73 61 6d | 70 6c 65 50 74 72 20 6f |er's sam|plePtr o|
|00001850| 72 20 6c 65 6e 67 68 74 | 2c 20 63 61 75 73 65 20 |r lenght|, cause |
|00001860| 74 68 6f 73 65 20 6d 61 | 79 20 63 6f 6e 74 61 69 |those ma|y contai|
|00001870| 6e 20 76 61 6c 69 64 20 | 65 6e 74 72 69 65 73 21 |n valid |entries!|
|00001880| 21 0d 09 09 09 09 09 74 | 68 65 48 65 61 64 65 72 |!......t|heHeader|
|00001890| 2d 3e 73 61 6d 70 6c 65 | 52 61 74 65 09 09 3d 20 |->sample|Rate..= |
|000018a0| 58 32 46 69 78 20 28 74 | 65 6d 70 6c 61 74 65 2d |X2Fix (t|emplate-|
|000018b0| 3e 63 6f 6d 6d 6f 6e 2e | 73 61 6d 70 6c 65 52 61 |>common.|sampleRa|
|000018c0| 74 65 29 3b 0d 09 09 09 | 09 09 74 68 65 48 65 61 |te);....|..theHea|
|000018d0| 64 65 72 2d 3e 6c 6f 6f | 70 53 74 61 72 74 09 09 |der->loo|pStart..|
|000018e0| 3d 20 30 3b 0d 09 09 09 | 09 09 74 68 65 48 65 61 |= 0;....|..theHea|
|000018f0| 64 65 72 2d 3e 6c 6f 6f | 70 45 6e 64 09 09 09 3d |der->loo|pEnd...=|
|00001900| 20 30 3b 0d 09 09 09 09 | 09 74 68 65 48 65 61 64 | 0;.....|.theHead|
|00001910| 65 72 2d 3e 65 6e 63 6f | 64 65 09 09 09 3d 20 30 |er->enco|de...= 0|
|00001920| 3b 0d 09 09 09 09 09 74 | 68 65 48 65 61 64 65 72 |;......t|heHeader|
|00001930| 2d 3e 62 61 73 65 46 72 | 65 71 75 65 6e 63 79 09 |->baseFr|equency.|
|00001940| 3d 20 36 30 3b 0d 0d 09 | 09 09 09 09 2f 2f 09 50 |= 60;...|....//.P|
|00001950| 65 72 68 61 70 73 20 73 | 6f 6d 65 20 65 78 70 6c |erhaps s|ome expl|
|00001960| 61 6e 61 74 69 6f 6e 20 | 69 73 20 69 6e 20 6f 72 |anation |is in or|
|00001970| 64 65 72 20 68 65 72 65 | 3a 20 20 77 65 27 72 65 |der here|: we're|
|00001980| 20 69 6e 74 65 72 65 73 | 74 65 64 20 69 6e 20 68 | interes|ted in h|
|00001990| 6f 77 20 6d 61 6e 79 20 | 62 79 74 65 73 20 6f 66 |ow many |bytes of|
|000019a0| 20 64 61 74 61 20 77 65 | 27 72 65 20 67 6f 69 6e | data we|'re goin|
|000019b0| 67 20 74 6f 0d 09 09 09 | 09 09 2f 2f 09 09 62 65 |g to....|..//..be|
|000019c0| 20 64 65 61 6c 69 6e 67 | 20 77 69 74 68 20 6c 61 | dealing| with la|
|000019d0| 74 65 72 20 6f 6e 2e 20 | 20 53 69 6e 63 65 20 41 |ter on. | Since A|
|000019e0| 49 46 46 20 69 73 20 69 | 6e 74 65 72 6c 65 61 76 |IFF is i|nterleav|
|000019f0| 65 64 2c 20 6d 75 6c 74 | 69 70 6c 79 20 74 68 65 |ed, mult|iply the|
|00001a00| 20 6e 75 6d 62 65 72 20 | 6f 66 20 63 68 61 6e 6e | number |of chann|
|00001a10| 65 6c 73 20 70 72 65 73 | 65 6e 74 20 62 79 0d 09 |els pres|ent by..|
|00001a20| 09 09 09 09 2f 2f 09 09 | 74 68 65 20 6e 75 6d 62 |....//..|the numb|
|00001a30| 65 72 20 6f 66 20 66 72 | 61 6d 65 73 20 69 6e 20 |er of fr|ames in |
|00001a40| 74 68 65 20 73 61 6d 70 | 6c 65 2c 20 62 79 20 74 |the samp|le, by t|
|00001a50| 68 65 20 6e 75 6d 62 65 | 72 20 6f 66 20 62 69 74 |he numbe|r of bit|
|00001a60| 73 20 70 65 72 20 73 61 | 6d 70 6c 65 2e 20 20 44 |s per sa|mple. D|
|00001a70| 69 76 69 64 65 20 62 79 | 20 38 20 62 69 74 73 2f |ivide by| 8 bits/|
|00001a80| 62 79 74 65 20 61 6e 64 | 0d 09 09 09 09 09 2f 2f |byte and|......//|
|00001a90| 09 09 79 6f 75 20 64 6f | 6e 65 20 67 6f 74 20 74 |..you do|ne got t|
|00001aa0| 68 65 20 6e 75 6d 62 65 | 72 20 6f 66 20 62 79 74 |he numbe|r of byt|
|00001ab0| 65 73 2e 20 20 53 6f 20 | 61 20 73 74 65 72 65 6f |es. So |a stereo|
|00001ac0| 20 38 20 62 69 74 20 73 | 61 6d 70 6c 65 20 61 63 | 8 bit s|ample ac|
|00001ad0| 74 75 61 6c 6c 79 20 6c | 6f 6f 6b 73 20 6c 69 6b |tually l|ooks lik|
|00001ae0| 65 20 74 68 69 73 3a 0d | 09 09 09 09 09 2f 2f 0d |e this:.|.....//.|
|00001af0| 09 09 09 09 09 2f 2f 20 | 20 20 20 20 20 20 20 7c |.....// | ||
|00001b00| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 20 20 66 |--------|----- f|
|00001b10| 72 61 6d 65 20 31 20 20 | 2d 2d 2d 2d 2d 2d 2d 2d |rame 1 |--------|
|00001b20| 2d 2d 2d 7c 20 20 7c 2d | 2d 2d 2d 2d 2d 2d 2d 2d |---| |-|--------|
|00001b30| 2d 2d 2d 2d 20 20 66 72 | 61 6d 65 20 32 20 20 2d |---- fr|ame 2 -|
|00001b40| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 7c 20 20 2e 2e 2e |--------|--| ...|
|00001b50| 0d 09 09 09 09 09 2f 2f | 0d 09 09 09 09 09 2f 2f |......//|......//|
|00001b60| 20 20 20 20 20 20 20 20 | 5b 7b 63 68 31 20 73 61 | |[{ch1 sa|
|00001b70| 6d 70 6c 65 20 70 74 20 | 31 7d 20 7b 63 68 32 20 |mple pt |1} {ch2 |
|00001b80| 73 61 6d 70 6c 65 20 70 | 74 20 31 7d 5d 20 20 5b |sample p|t 1}] [|
|00001b90| 7b 63 68 31 20 73 61 6d | 70 6c 65 20 70 74 20 32 |{ch1 sam|ple pt 2|
|00001ba0| 7d 20 7b 63 68 32 20 73 | 61 6d 70 6c 65 20 70 74 |} {ch2 s|ample pt|
|00001bb0| 20 32 7d 5d 20 20 2e 2e | 2e 0d 0d 09 09 09 09 09 | 2}] ..|........|
|00001bc0| 64 61 74 61 53 69 7a 65 | 20 3d 20 28 74 65 6d 70 |dataSize| = (temp|
|00001bd0| 6c 61 74 65 2d 3e 63 6f | 6d 6d 6f 6e 2e 6e 75 6d |late->co|mmon.num|
|00001be0| 43 68 61 6e 6e 65 6c 73 | 20 2a 20 74 65 6d 70 6c |Channels| * templ|
|00001bf0| 61 74 65 2d 3e 63 6f 6d | 6d 6f 6e 2e 6e 75 6d 53 |ate->com|mon.numS|
|00001c00| 61 6d 70 6c 65 46 72 61 | 6d 65 73 20 2a 20 74 65 |ampleFra|mes * te|
|00001c10| 6d 70 6c 61 74 65 2d 3e | 63 6f 6d 6d 6f 6e 2e 73 |mplate->|common.s|
|00001c20| 61 6d 70 6c 65 53 69 7a | 65 29 20 2f 20 38 3b 0d |ampleSiz|e) / 8;.|
|00001c30| 09 09 09 09 09 65 72 72 | 20 3d 20 6e 6f 45 72 72 |.....err| = noErr|
|00001c40| 3b 0d 09 09 09 09 7d 0d | 09 09 09 09 62 72 65 61 |;.....}.|....brea|
|00001c50| 6b 3b 0d 0d 0d 09 09 09 | 63 61 73 65 20 53 6f 75 |k;......|case Sou|
|00001c60| 6e 64 44 61 74 61 49 44 | 3a 0d 09 09 09 09 44 65 |ndDataID|:.....De|
|00001c70| 62 75 67 4d 65 73 73 61 | 67 65 20 28 22 5c 70 66 |bugMessa|ge ("\pf|
|00001c80| 6f 75 6e 64 20 74 68 65 | 20 73 6f 75 6e 64 20 63 |ound the| sound c|
|00001c90| 68 75 6e 6b 22 29 3b 0d | 09 09 09 09 41 73 73 65 |hunk");.|....Asse|
|00001ca0| 72 74 20 28 28 63 68 75 | 6e 6b 46 6c 61 67 73 20 |rt ((chu|nkFlags |
|00001cb0| 26 20 6b 53 6f 75 6e 64 | 44 61 74 61 29 2c 20 22 |& kSound|Data), "|
|00001cc0| 5c 70 4f 48 20 4e 4f 21 | 21 20 46 6f 75 6e 64 20 |\pOH NO!|! Found |
|00001cd0| 61 20 64 75 70 6c 69 63 | 61 74 65 20 73 6f 75 6e |a duplic|ate soun|
|00001ce0| 64 20 64 61 74 61 20 43 | 68 75 6e 6b 21 21 22 29 |d data C|hunk!!")|
|00001cf0| 3b 0d 0d 09 09 09 09 69 | 66 20 28 20 21 28 63 68 |;......i|f ( !(ch|
|00001d00| 75 6e 6b 46 6c 61 67 73 | 20 26 20 6b 53 6f 75 6e |unkFlags| & kSoun|
|00001d10| 64 44 61 74 61 29 20 29 | 20 7b 09 09 09 09 09 09 |dData) )| {......|
|00001d20| 09 09 09 09 09 09 09 09 | 09 2f 2f 20 20 73 65 65 |........|.// see|
|00001d30| 20 69 66 20 74 68 69 73 | 20 63 68 75 6e 6b 20 61 | if this| chunk a|
|00001d40| 6c 72 65 61 64 79 20 65 | 78 69 73 74 73 0d 0d 09 |lready e|xists...|
|00001d50| 09 09 09 09 2f 2f 09 4c | 65 74 27 73 20 72 65 6d |....//.L|et's rem|
|00001d60| 65 6d 62 65 72 20 77 68 | 65 72 65 20 74 68 65 20 |ember wh|ere the |
|00001d70| 53 6f 75 6e 64 20 44 61 | 74 61 20 73 74 61 72 74 |Sound Da|ta start|
|00001d80| 73 2c 20 73 6f 20 77 65 | 20 63 61 6e 20 66 69 6e |s, so we| can fin|
|00001d90| 64 20 74 68 65 20 70 6f | 73 69 74 69 6f 6e 20 69 |d the po|sition i|
|00001da0| 6e 20 74 68 65 20 66 69 | 6c 65 20 6c 61 74 65 72 |n the fi|le later|
|00001db0| 2e 0d 09 09 09 09 09 2f | 2f 20 20 54 68 65 20 6d |......./|/ The m|
|00001dc0| 61 72 6b 20 77 69 6c 6c | 20 62 65 20 70 6f 73 69 |ark will| be posi|
|00001dd0| 74 69 6f 6e 65 64 20 61 | 74 20 74 68 65 20 62 65 |tioned a|t the be|
|00001de0| 67 69 6e 6e 69 6e 67 20 | 6f 66 20 74 68 65 20 63 |ginning |of the c|
|00001df0| 68 75 6e 6b 2c 20 73 6f | 20 6d 6f 76 65 20 31 36 |hunk, so| move 16|
|00001e00| 20 62 79 74 65 73 20 70 | 61 73 74 20 74 6f 20 67 | bytes p|ast to g|
|00001e10| 65 74 20 70 61 73 74 0d | 09 09 09 09 09 2f 2f 09 |et past.|.....//.|
|00001e20| 74 68 65 20 68 65 61 64 | 65 72 20 69 6e 66 6f 72 |the head|er infor|
|00001e30| 6d 61 74 69 6f 6e 20 74 | 6f 20 74 68 65 20 64 61 |mation t|o the da|
|00001e40| 74 61 2e 0d 09 09 09 09 | 09 64 61 74 61 53 74 61 |ta......|.dataSta|
|00001e50| 72 74 20 3d 20 66 69 6c | 65 50 6f 73 69 74 69 6f |rt = fil|ePositio|
|00001e60| 6e 20 2b 20 31 36 3b 0d | 0d 09 09 09 09 09 63 68 |n + 16;.|......ch|
|00001e70| 75 6e 6b 46 6c 61 67 73 | 20 7c 3d 20 6b 53 6f 75 |unkFlags| |= kSou|
|00001e80| 6e 64 44 61 74 61 3b 09 | 09 09 09 09 09 09 09 09 |ndData;.|........|
|00001e90| 09 09 09 09 09 09 2f 2f | 09 09 6f 74 68 65 72 77 |......//|..otherw|
|00001ea0| 69 73 65 20 6d 61 72 6b | 20 69 74 20 66 6f 75 6e |ise mark| it foun|
|00001eb0| 64 0d 09 09 09 09 09 66 | 69 6c 65 50 6f 73 69 74 |d......f|ilePosit|
|00001ec0| 69 6f 6e 20 2b 3d 20 74 | 65 6d 70 6c 61 74 65 2d |ion += t|emplate-|
|00001ed0| 3e 73 6f 75 6e 64 44 61 | 74 61 2e 63 6b 53 69 7a |>soundDa|ta.ckSiz|
|00001ee0| 65 20 2b 20 6b 43 68 75 | 6e 6b 48 65 61 64 65 72 |e + kChu|nkHeader|
|00001ef0| 53 69 7a 65 3b 09 09 09 | 09 09 09 2f 2f 09 09 63 |Size;...|...//..c|
|00001f00| 61 6c 63 75 6c 61 74 65 | 20 6e 65 78 74 20 63 68 |alculate| next ch|
|00001f10| 75 6e 6b 27 73 20 70 6f | 73 69 74 69 6f 6e 0d 09 |unk's po|sition..|
|00001f20| 09 09 09 09 65 72 72 20 | 3d 20 6e 6f 45 72 72 3b |....err |= noErr;|
|00001f30| 0d 09 09 09 09 7d 0d 09 | 09 09 09 62 72 65 61 6b |.....}..|...break|
|00001f40| 3b 0d 0d 0d 0d 0d 09 09 | 09 2f 2f 0d 09 09 09 2f |;.......|.//..../|
|00001f50| 2f 20 20 20 20 54 68 65 | 20 66 6f 6c 6c 6f 77 69 |/ The| followi|
|00001f60| 6e 67 20 6c 69 73 74 20 | 6f 66 20 63 68 75 6e 6b |ng list |of chunk|
|00001f70| 73 20 77 65 20 64 6f 6e | 27 74 20 63 61 72 65 20 |s we don|'t care |
|00001f80| 61 62 6f 75 74 2c 20 73 | 6f 20 77 65 27 6c 6c 20 |about, s|o we'll |
|00001f90| 6a 75 73 74 20 73 6b 69 | 70 20 6f 76 65 72 20 74 |just ski|p over t|
|00001fa0| 68 65 6d 2e 0d 09 09 09 | 2f 2f 0d 09 09 09 63 61 |hem.....|//....ca|
|00001fb0| 73 65 20 4d 61 72 6b 65 | 72 49 44 3a 0d 09 09 09 |se Marke|rID:....|
|00001fc0| 09 44 65 62 75 67 4d 65 | 73 73 61 67 65 20 28 22 |.DebugMe|ssage ("|
|00001fd0| 5c 70 66 6f 75 6e 64 20 | 61 20 6d 61 72 6b 65 72 |\pfound |a marker|
|00001fe0| 20 63 68 75 6e 6b 22 29 | 3b 0d 09 09 09 09 41 73 | chunk")|;.....As|
|00001ff0| 73 65 72 74 20 28 28 63 | 68 75 6e 6b 46 6c 61 67 |sert ((c|hunkFlag|
|00002000| 73 20 26 20 6b 4d 61 72 | 6b 65 72 29 2c 20 22 5c |s & kMar|ker), "\|
|00002010| 70 4f 48 20 4e 4f 21 21 | 20 46 6f 75 6e 64 20 61 |pOH NO!!| Found a|
|00002020| 20 64 75 70 6c 69 63 61 | 74 65 20 6d 61 72 6b 65 | duplica|te marke|
|00002030| 72 20 43 68 75 6e 6b 21 | 21 22 29 3b 0d 0d 09 09 |r Chunk!|!");....|
|00002040| 09 09 69 66 20 28 20 21 | 28 63 68 75 6e 6b 46 6c |..if ( !|(chunkFl|
|00002050| 61 67 73 20 26 20 6b 4d | 61 72 6b 65 72 29 20 29 |ags & kM|arker) )|
|00002060| 20 7b 09 09 09 09 09 09 | 09 09 09 09 09 09 09 09 | {......|........|
|00002070| 09 2f 2f 20 20 73 65 65 | 20 69 66 20 74 68 69 73 |.// see| if this|
|00002080| 20 63 68 75 6e 6b 20 61 | 6c 72 65 61 64 79 20 65 | chunk a|lready e|
|00002090| 78 69 73 74 73 0d 09 09 | 09 09 09 63 68 75 6e 6b |xists...|...chunk|
|000020a0| 46 6c 61 67 73 20 7c 3d | 20 6b 4d 61 72 6b 65 72 |Flags |=| kMarker|
|000020b0| 3b 09 09 09 09 09 09 09 | 09 09 09 09 09 09 09 09 |;.......|........|
|000020c0| 09 2f 2f 09 09 6f 74 68 | 65 72 77 69 73 65 20 6d |.//..oth|erwise m|
|000020d0| 61 72 6b 20 69 74 20 66 | 6f 75 6e 64 0d 09 09 09 |ark it f|ound....|
|000020e0| 09 09 66 69 6c 65 50 6f | 73 69 74 69 6f 6e 20 2b |..filePo|sition +|
|000020f0| 3d 20 74 65 6d 70 6c 61 | 74 65 2d 3e 6d 61 72 6b |= templa|te->mark|
|00002100| 65 72 2e 63 6b 53 69 7a | 65 20 2b 20 6b 43 68 75 |er.ckSiz|e + kChu|
|00002110| 6e 6b 48 65 61 64 65 72 | 53 69 7a 65 3b 09 09 09 |nkHeader|Size;...|
|00002120| 09 09 09 09 2f 2f 09 09 | 63 61 6c 63 75 6c 61 74 |....//..|calculat|
|00002130| 65 20 6e 65 78 74 20 63 | 68 75 6e 6b 27 73 20 70 |e next c|hunk's p|
|00002140| 6f 73 69 74 69 6f 6e 0d | 09 09 09 09 09 65 72 72 |osition.|.....err|
|00002150| 20 3d 20 6e 6f 45 72 72 | 3b 0d 09 09 09 09 7d 0d | = noErr|;.....}.|
|00002160| 09 09 09 09 62 72 65 61 | 6b 3b 0d 0d 0d 09 09 09 |....brea|k;......|
|00002170| 63 61 73 65 20 43 6f 6d | 6d 65 6e 74 49 44 3a 0d |case Com|mentID:.|
|00002180| 09 09 09 09 44 65 62 75 | 67 4d 65 73 73 61 67 65 |....Debu|gMessage|
|00002190| 20 28 22 5c 70 66 6f 75 | 6e 64 20 61 20 63 6f 6d | ("\pfou|nd a com|
|000021a0| 6d 65 6e 74 20 63 68 75 | 6e 6b 22 29 3b 0d 09 09 |ment chu|nk");...|
|000021b0| 09 09 41 73 73 65 72 74 | 20 28 28 63 68 75 6e 6b |..Assert| ((chunk|
|000021c0| 46 6c 61 67 73 20 26 20 | 6b 43 6f 6d 6d 65 6e 74 |Flags & |kComment|
|000021d0| 29 2c 20 22 5c 70 4f 48 | 20 4e 4f 21 21 20 46 6f |), "\pOH| NO!! Fo|
|000021e0| 75 6e 64 20 61 20 64 75 | 70 6c 69 63 61 74 65 20 |und a du|plicate |
|000021f0| 63 6f 6d 6d 65 6e 74 20 | 43 68 75 6e 6b 21 21 22 |comment |Chunk!!"|
|00002200| 29 3b 0d 0d 09 09 09 09 | 69 66 20 28 20 21 28 63 |);......|if ( !(c|
|00002210| 68 75 6e 6b 46 6c 61 67 | 73 20 26 20 6b 43 6f 6d |hunkFlag|s & kCom|
|00002220| 6d 65 6e 74 29 20 29 20 | 7b 09 09 09 09 09 09 09 |ment) ) |{.......|
|00002230| 09 09 09 09 09 09 09 09 | 2f 2f 20 20 73 65 65 20 |........|// see |
|00002240| 69 66 20 74 68 69 73 20 | 63 68 75 6e 6b 20 61 6c |if this |chunk al|
|00002250| 72 65 61 64 79 20 65 78 | 69 73 74 73 0d 09 09 09 |ready ex|ists....|
|00002260| 09 09 63 68 75 6e 6b 46 | 6c 61 67 73 20 7c 3d 20 |..chunkF|lags |= |
|00002270| 6b 43 6f 6d 6d 65 6e 74 | 3b 09 09 09 09 09 09 09 |kComment|;.......|
|00002280| 09 09 09 09 09 09 09 09 | 09 2f 2f 09 09 6f 74 68 |........|.//..oth|
|00002290| 65 72 77 69 73 65 20 6d | 61 72 6b 20 69 74 20 66 |erwise m|ark it f|
|000022a0| 6f 75 6e 64 0d 09 09 09 | 09 09 66 69 6c 65 50 6f |ound....|..filePo|
|000022b0| 73 69 74 69 6f 6e 20 2b | 3d 20 74 65 6d 70 6c 61 |sition +|= templa|
|000022c0| 74 65 2d 3e 6d 61 72 6b | 65 72 2e 63 6b 53 69 7a |te->mark|er.ckSiz|
|000022d0| 65 20 2b 20 6b 43 68 75 | 6e 6b 48 65 61 64 65 72 |e + kChu|nkHeader|
|000022e0| 53 69 7a 65 3b 09 09 09 | 09 09 09 09 2f 2f 09 09 |Size;...|....//..|
|000022f0| 63 61 6c 63 75 6c 61 74 | 65 20 6e 65 78 74 20 63 |calculat|e next c|
|00002300| 68 75 6e 6b 27 73 20 70 | 6f 73 69 74 69 6f 6e 0d |hunk's p|osition.|
|00002310| 09 09 09 09 09 65 72 72 | 20 3d 20 6e 6f 45 72 72 |.....err| = noErr|
|00002320| 3b 0d 09 09 09 09 7d 0d | 09 09 09 09 62 72 65 61 |;.....}.|....brea|
|00002330| 6b 3b 0d 0d 0d 09 09 09 | 63 61 73 65 20 49 6e 73 |k;......|case Ins|
|00002340| 74 72 75 6d 65 6e 74 49 | 44 3a 0d 09 09 09 09 44 |trumentI|D:.....D|
|00002350| 65 62 75 67 4d 65 73 73 | 61 67 65 20 28 22 5c 70 |ebugMess|age ("\p|
|00002360| 66 6f 75 6e 64 20 61 6e | 20 69 6e 73 74 72 75 6d |found an| instrum|
|00002370| 65 6e 74 20 63 68 75 6e | 6b 22 29 3b 0d 09 09 09 |ent chun|k");....|
|00002380| 09 41 73 73 65 72 74 20 | 28 28 63 68 75 6e 6b 46 |.Assert |((chunkF|
|00002390| 6c 61 67 73 20 26 20 6b | 49 6e 73 74 72 75 6d 65 |lags & k|Instrume|
|000023a0| 6e 74 29 2c 20 22 5c 70 | 4f 48 20 4e 4f 21 21 20 |nt), "\p|OH NO!! |
|000023b0| 46 6f 75 6e 64 20 61 20 | 64 75 70 6c 69 63 61 74 |Found a |duplicat|
|000023c0| 65 20 69 6e 73 74 72 75 | 6d 65 6e 74 20 43 68 75 |e instru|ment Chu|
|000023d0| 6e 6b 21 21 22 29 3b 0d | 0d 09 09 09 09 69 66 20 |nk!!");.|.....if |
|000023e0| 28 20 21 28 63 68 75 6e | 6b 46 6c 61 67 73 20 26 |( !(chun|kFlags &|
|000023f0| 20 6b 49 6e 73 74 72 75 | 6d 65 6e 74 29 20 29 20 | kInstru|ment) ) |
|00002400| 7b 09 09 09 09 09 09 09 | 09 09 09 09 09 09 09 2f |{.......|......./|
|00002410| 2f 20 20 73 65 65 20 69 | 66 20 74 68 69 73 20 63 |/ see i|f this c|
|00002420| 68 75 6e 6b 20 61 6c 72 | 65 61 64 79 20 65 78 69 |hunk alr|eady exi|
|00002430| 73 74 73 0d 09 09 09 09 | 09 63 68 75 6e 6b 46 6c |sts.....|.chunkFl|
|00002440| 61 67 73 20 7c 3d 20 6b | 49 6e 73 74 72 75 6d 65 |ags |= k|Instrume|
|00002450| 6e 74 3b 09 09 09 09 09 | 09 09 09 09 09 09 09 09 |nt;.....|........|
|00002460| 09 09 2f 2f 09 09 6f 74 | 68 65 72 77 69 73 65 20 |..//..ot|herwise |
|00002470| 6d 61 72 6b 20 69 74 20 | 66 6f 75 6e 64 0d 09 09 |mark it |found...|
|00002480| 09 09 09 66 69 6c 65 50 | 6f 73 69 74 69 6f 6e 20 |...fileP|osition |
|00002490| 2b 3d 20 74 65 6d 70 6c | 61 74 65 2d 3e 69 6e 73 |+= templ|ate->ins|
|000024a0| 74 72 75 6d 65 6e 74 2e | 63 6b 53 69 7a 65 20 2b |trument.|ckSize +|
|000024b0| 20 6b 43 68 75 6e 6b 48 | 65 61 64 65 72 53 69 7a | kChunkH|eaderSiz|
|000024c0| 65 3b 09 09 09 09 09 09 | 2f 2f 09 09 63 61 6c 63 |e;......|//..calc|
|000024d0| 75 6c 61 74 65 20 6e 65 | 78 74 20 63 68 75 6e 6b |ulate ne|xt chunk|
|000024e0| 27 73 20 70 6f 73 69 74 | 69 6f 6e 0d 09 09 09 09 |'s posit|ion.....|
|000024f0| 09 65 72 72 20 3d 20 6e | 6f 45 72 72 3b 0d 09 09 |.err = n|oErr;...|
|00002500| 09 09 7d 0d 09 09 09 09 | 62 72 65 61 6b 3b 0d 0d |..}.....|break;..|
|00002510| 0d 09 09 09 63 61 73 65 | 20 4d 49 44 49 44 61 74 |....case| MIDIDat|
|00002520| 61 49 44 3a 0d 09 09 09 | 09 44 65 62 75 67 4d 65 |aID:....|.DebugMe|
|00002530| 73 73 61 67 65 20 28 22 | 5c 70 66 6f 75 6e 64 20 |ssage ("|\pfound |
|00002540| 61 20 4d 49 44 49 20 44 | 61 74 61 20 63 68 75 6e |a MIDI D|ata chun|
|00002550| 6b 22 29 3b 0d 09 09 09 | 09 41 73 73 65 72 74 20 |k");....|.Assert |
|00002560| 28 28 63 68 75 6e 6b 46 | 6c 61 67 73 20 26 20 6b |((chunkF|lags & k|
|00002570| 4d 49 44 49 44 61 74 61 | 29 2c 20 22 5c 70 4f 48 |MIDIData|), "\pOH|
|00002580| 20 4e 4f 21 21 20 46 6f | 75 6e 64 20 61 20 64 75 | NO!! Fo|und a du|
|00002590| 70 6c 69 63 61 74 65 20 | 4d 49 44 49 20 43 68 75 |plicate |MIDI Chu|
|000025a0| 6e 6b 21 21 22 29 3b 0d | 0d 09 09 09 09 69 66 20 |nk!!");.|.....if |
|000025b0| 28 20 21 28 63 68 75 6e | 6b 46 6c 61 67 73 20 26 |( !(chun|kFlags &|
|000025c0| 20 6b 4d 49 44 49 44 61 | 74 61 29 20 29 20 7b 09 | kMIDIDa|ta) ) {.|
|000025d0| 09 09 09 09 09 09 09 09 | 09 09 09 09 09 09 2f 2f |........|......//|
|000025e0| 20 20 73 65 65 20 69 66 | 20 74 68 69 73 20 63 68 | see if| this ch|
|000025f0| 75 6e 6b 20 61 6c 72 65 | 61 64 79 20 65 78 69 73 |unk alre|ady exis|
|00002600| 74 73 0d 09 09 09 09 09 | 63 68 75 6e 6b 46 6c 61 |ts......|chunkFla|
|00002610| 67 73 20 7c 3d 20 6b 4d | 49 44 49 44 61 74 61 3b |gs |= kM|IDIData;|
|00002620| 09 09 09 09 09 09 09 09 | 09 09 09 09 09 09 09 2f |........|......./|
|00002630| 2f 09 09 6f 74 68 65 72 | 77 69 73 65 20 6d 61 72 |/..other|wise mar|
|00002640| 6b 20 69 74 20 66 6f 75 | 6e 64 0d 09 09 09 09 09 |k it fou|nd......|
|00002650| 66 69 6c 65 50 6f 73 69 | 74 69 6f 6e 20 2b 3d 20 |filePosi|tion += |
|00002660| 74 65 6d 70 6c 61 74 65 | 2d 3e 6d 69 64 69 44 61 |template|->midiDa|
|00002670| 74 61 2e 63 6b 53 69 7a | 65 20 2b 20 6b 43 68 75 |ta.ckSiz|e + kChu|
|00002680| 6e 6b 48 65 61 64 65 72 | 53 69 7a 65 3b 09 09 09 |nkHeader|Size;...|
|00002690| 09 09 09 2f 2f 09 09 63 | 61 6c 63 75 6c 61 74 65 |...//..c|alculate|
|000026a0| 20 6e 65 78 74 20 63 68 | 75 6e 6b 27 73 20 70 6f | next ch|unk's po|
|000026b0| 73 69 74 69 6f 6e 0d 09 | 09 09 09 09 65 72 72 20 |sition..|....err |
|000026c0| 3d 20 6e 6f 45 72 72 3b | 0d 09 09 09 09 7d 0d 09 |= noErr;|.....}..|
|000026d0| 09 09 09 62 72 65 61 6b | 3b 0d 0d 0d 09 09 09 63 |...break|;......c|
|000026e0| 61 73 65 20 41 75 64 69 | 6f 52 65 63 6f 72 64 69 |ase Audi|oRecordi|
|000026f0| 6e 67 49 44 3a 0d 09 09 | 09 09 44 65 62 75 67 4d |ngID:...|..DebugM|
|00002700| 65 73 73 61 67 65 20 28 | 22 5c 70 66 6f 75 6e 64 |essage (|"\pfound|
|00002710| 20 61 6e 20 61 75 64 69 | 6f 20 72 65 63 6f 72 64 | an audi|o record|
|00002720| 69 6e 67 20 63 68 75 6e | 6b 22 29 3b 0d 09 09 09 |ing chun|k");....|
|00002730| 09 41 73 73 65 72 74 20 | 28 28 63 68 75 6e 6b 46 |.Assert |((chunkF|
|00002740| 6c 61 67 73 20 26 20 6b | 41 75 64 69 6f 52 65 63 |lags & k|AudioRec|
|00002750| 6f 72 64 69 6e 67 29 2c | 20 22 5c 70 4f 48 20 4e |ording),| "\pOH N|
|00002760| 4f 21 21 20 46 6f 75 6e | 64 20 61 20 64 75 70 6c |O!! Foun|d a dupl|
|00002770| 69 63 61 74 65 20 41 75 | 64 69 6f 20 52 65 63 6f |icate Au|dio Reco|
|00002780| 72 64 69 6e 67 20 43 68 | 75 6e 6b 21 21 22 29 3b |rding Ch|unk!!");|
|00002790| 0d 0d 09 09 09 09 69 66 | 20 28 20 21 28 63 68 75 |......if| ( !(chu|
|000027a0| 6e 6b 46 6c 61 67 73 20 | 26 20 6b 41 75 64 69 6f |nkFlags |& kAudio|
|000027b0| 52 65 63 6f 72 64 69 6e | 67 29 20 29 20 7b 09 09 |Recordin|g) ) {..|
|000027c0| 09 09 09 09 09 09 09 09 | 09 09 09 2f 2f 20 20 73 |........|...// s|
|000027d0| 65 65 20 69 66 20 74 68 | 69 73 20 63 68 75 6e 6b |ee if th|is chunk|
|000027e0| 20 61 6c 72 65 61 64 79 | 20 65 78 69 73 74 73 0d | already| exists.|
|000027f0| 09 09 09 09 09 63 68 75 | 6e 6b 46 6c 61 67 73 20 |.....chu|nkFlags |
|00002800| 7c 3d 20 6b 41 75 64 69 | 6f 52 65 63 6f 72 64 69 ||= kAudi|oRecordi|
|00002810| 6e 67 3b 09 09 09 09 09 | 09 09 09 09 09 09 09 09 |ng;.....|........|
|00002820| 09 2f 2f 09 09 6f 74 68 | 65 72 77 69 73 65 20 6d |.//..oth|erwise m|
|00002830| 61 72 6b 20 69 74 20 66 | 6f 75 6e 64 0d 09 09 09 |ark it f|ound....|
|00002840| 09 09 66 69 6c 65 50 6f | 73 69 74 69 6f 6e 20 2b |..filePo|sition +|
|00002850| 3d 20 74 65 6d 70 6c 61 | 74 65 2d 3e 61 75 64 69 |= templa|te->audi|
|00002860| 6f 52 65 63 6f 72 64 69 | 6e 67 2e 63 6b 53 69 7a |oRecordi|ng.ckSiz|
|00002870| 65 20 2b 20 6b 43 68 75 | 6e 6b 48 65 61 64 65 72 |e + kChu|nkHeader|
|00002880| 53 69 7a 65 3b 09 09 09 | 09 09 2f 2f 09 09 63 61 |Size;...|..//..ca|
|00002890| 6c 63 75 6c 61 74 65 20 | 6e 65 78 74 20 63 68 75 |lculate |next chu|
|000028a0| 6e 6b 27 73 20 70 6f 73 | 69 74 69 6f 6e 0d 09 09 |nk's pos|ition...|
|000028b0| 09 09 09 65 72 72 20 3d | 20 6e 6f 45 72 72 3b 0d |...err =| noErr;.|
|000028c0| 09 09 09 09 7d 0d 09 09 | 09 09 62 72 65 61 6b 3b |....}...|..break;|
|000028d0| 0d 0d 0d 09 09 09 63 61 | 73 65 20 41 70 70 6c 69 |......ca|se Appli|
|000028e0| 63 61 74 69 6f 6e 53 70 | 65 63 69 66 69 63 49 44 |cationSp|ecificID|
|000028f0| 3a 0d 09 09 09 09 44 65 | 62 75 67 4d 65 73 73 61 |:.....De|bugMessa|
|00002900| 67 65 20 28 22 5c 70 66 | 6f 75 6e 64 20 61 6e 20 |ge ("\pf|ound an |
|00002910| 61 70 70 6c 69 63 61 74 | 69 6f 6e 20 73 70 65 63 |applicat|ion spec|
|00002920| 69 66 69 20 63 68 75 6e | 6b 22 29 3b 0d 09 09 09 |ifi chun|k");....|
|00002930| 09 41 73 73 65 72 74 20 | 28 28 63 68 75 6e 6b 46 |.Assert |((chunkF|
|00002940| 6c 61 67 73 20 26 20 6b | 41 70 70 6c 69 63 61 74 |lags & k|Applicat|
|00002950| 69 6f 6e 53 70 65 63 69 | 66 69 63 29 2c 20 22 5c |ionSpeci|fic), "\|
|00002960| 70 4f 48 20 4e 4f 21 21 | 20 46 6f 75 6e 64 20 61 |pOH NO!!| Found a|
|00002970| 20 64 75 70 6c 69 63 61 | 74 65 20 61 70 70 6c 69 | duplica|te appli|
|00002980| 63 61 74 69 6f 6e 20 73 | 70 65 63 69 66 69 63 20 |cation s|pecific |
|00002990| 43 68 75 6e 6b 21 21 22 | 29 3b 0d 0d 09 09 09 09 |Chunk!!"|);......|
|000029a0| 69 66 20 28 20 21 28 63 | 68 75 6e 6b 46 6c 61 67 |if ( !(c|hunkFlag|
|000029b0| 73 20 26 20 6b 41 70 70 | 6c 69 63 61 74 69 6f 6e |s & kApp|lication|
|000029c0| 53 70 65 63 69 66 69 63 | 29 20 29 20 7b 09 09 09 |Specific|) ) {...|
|000029d0| 09 09 09 09 09 09 09 09 | 09 2f 2f 20 20 73 65 65 |........|.// see|
|000029e0| 20 69 66 20 74 68 69 73 | 20 63 68 75 6e 6b 20 61 | if this| chunk a|
|000029f0| 6c 72 65 61 64 79 20 65 | 78 69 73 74 73 0d 09 09 |lready e|xists...|
|00002a00| 09 09 09 63 68 75 6e 6b | 46 6c 61 67 73 20 7c 3d |...chunk|Flags |=|
|00002a10| 20 6b 41 70 70 6c 69 63 | 61 74 69 6f 6e 53 70 65 | kApplic|ationSpe|
|00002a20| 63 69 66 69 63 3b 09 09 | 09 09 09 09 09 09 09 09 |cific;..|........|
|00002a30| 09 09 09 2f 2f 09 09 6f | 74 68 65 72 77 69 73 65 |...//..o|therwise|
|00002a40| 20 6d 61 72 6b 20 69 74 | 20 66 6f 75 6e 64 0d 09 | mark it| found..|
|00002a50| 09 09 09 09 66 69 6c 65 | 50 6f 73 69 74 69 6f 6e |....file|Position|
|00002a60| 20 2b 3d 20 74 65 6d 70 | 6c 61 74 65 2d 3e 67 65 | += temp|late->ge|
|00002a70| 6e 65 72 69 63 2e 63 6b | 53 69 7a 65 20 2b 20 6b |neric.ck|Size + k|
|00002a80| 43 68 75 6e 6b 48 65 61 | 64 65 72 53 69 7a 65 3b |ChunkHea|derSize;|
|00002a90| 09 09 09 09 09 09 2f 2f | 09 09 63 61 6c 63 75 6c |......//|..calcul|
|00002aa0| 61 74 65 20 6e 65 78 74 | 20 63 68 75 6e 6b 27 73 |ate next| chunk's|
|00002ab0| 20 70 6f 73 69 74 69 6f | 6e 0d 09 09 09 09 09 65 | positio|n......e|
|00002ac0| 72 72 20 3d 20 6e 6f 45 | 72 72 3b 0d 09 09 09 09 |rr = noE|rr;.....|
|00002ad0| 7d 0d 09 09 09 09 62 72 | 65 61 6b 3b 0d 0d 0d 09 |}.....br|eak;....|
|00002ae0| 09 09 63 61 73 65 20 4e | 61 6d 65 49 44 3a 0d 09 |..case N|ameID:..|
|00002af0| 09 09 09 44 65 62 75 67 | 4d 65 73 73 61 67 65 20 |...Debug|Message |
|00002b00| 28 22 5c 70 66 6f 75 6e | 64 20 61 20 6e 61 6d 65 |("\pfoun|d a name|
|00002b10| 20 63 68 75 6e 6b 22 29 | 3b 0d 09 09 09 09 41 73 | chunk")|;.....As|
|00002b20| 73 65 72 74 20 28 28 63 | 68 75 6e 6b 46 6c 61 67 |sert ((c|hunkFlag|
|00002b30| 73 20 26 20 6b 4e 61 6d | 65 29 2c 20 22 5c 70 4f |s & kNam|e), "\pO|
|00002b40| 48 20 4e 4f 21 21 20 46 | 6f 75 6e 64 20 61 20 64 |H NO!! F|ound a d|
|00002b50| 75 70 6c 69 63 61 74 65 | 20 6e 61 6d 65 20 43 68 |uplicate| name Ch|
|00002b60| 75 6e 6b 21 21 22 29 3b | 0d 0d 09 09 09 09 69 66 |unk!!");|......if|
|00002b70| 20 28 20 21 28 63 68 75 | 6e 6b 46 6c 61 67 73 20 | ( !(chu|nkFlags |
|00002b80| 26 20 6b 4e 61 6d 65 29 | 20 29 20 7b 09 09 09 09 |& kName)| ) {....|
|00002b90| 09 09 09 09 09 09 09 09 | 09 09 09 09 2f 2f 20 20 |........|....// |
|00002ba0| 73 65 65 20 69 66 20 74 | 68 69 73 20 63 68 75 6e |see if t|his chun|
|00002bb0| 6b 20 61 6c 72 65 61 64 | 79 20 65 78 69 73 74 73 |k alread|y exists|
|00002bc0| 0d 09 09 09 09 09 63 68 | 75 6e 6b 46 6c 61 67 73 |......ch|unkFlags|
|00002bd0| 20 7c 3d 20 6b 4e 61 6d | 65 3b 09 09 09 09 09 09 | |= kNam|e;......|
|00002be0| 09 09 09 09 09 09 09 09 | 09 09 2f 2f 09 09 6f 74 |........|..//..ot|
|00002bf0| 68 65 72 77 69 73 65 20 | 6d 61 72 6b 20 69 74 20 |herwise |mark it |
|00002c00| 66 6f 75 6e 64 0d 09 09 | 09 09 09 66 69 6c 65 50 |found...|...fileP|
|00002c10| 6f 73 69 74 69 6f 6e 20 | 2b 3d 20 74 65 6d 70 6c |osition |+= templ|
|00002c20| 61 74 65 2d 3e 67 65 6e | 65 72 69 63 2e 63 6b 53 |ate->gen|eric.ckS|
|00002c30| 69 7a 65 20 2b 20 6b 43 | 68 75 6e 6b 48 65 61 64 |ize + kC|hunkHead|
|00002c40| 65 72 53 69 7a 65 3b 09 | 09 09 09 09 09 2f 2f 09 |erSize;.|.....//.|
|00002c50| 09 63 61 6c 63 75 6c 61 | 74 65 20 6e 65 78 74 20 |.calcula|te next |
|00002c60| 63 68 75 6e 6b 27 73 20 | 70 6f 73 69 74 69 6f 6e |chunk's |position|
|00002c70| 0d 09 09 09 09 09 65 72 | 72 20 3d 20 6e 6f 45 72 |......er|r = noEr|
|00002c80| 72 3b 0d 09 09 09 09 7d | 0d 09 09 09 09 62 72 65 |r;.....}|.....bre|
|00002c90| 61 6b 3b 0d 0d 0d 09 09 | 09 63 61 73 65 20 41 75 |ak;.....|.case Au|
|00002ca0| 74 68 6f 72 49 44 3a 0d | 09 09 09 09 44 65 62 75 |thorID:.|....Debu|
|00002cb0| 67 4d 65 73 73 61 67 65 | 20 28 22 5c 70 66 6f 75 |gMessage| ("\pfou|
|00002cc0| 6e 64 20 61 6e 20 61 75 | 74 68 6f 72 20 63 68 75 |nd an au|thor chu|
|00002cd0| 6e 6b 22 29 3b 0d 09 09 | 09 09 41 73 73 65 72 74 |nk");...|..Assert|
|00002ce0| 20 28 28 63 68 75 6e 6b | 46 6c 61 67 73 20 26 20 | ((chunk|Flags & |
|00002cf0| 6b 41 75 74 68 6f 72 29 | 2c 20 22 5c 70 4f 48 20 |kAuthor)|, "\pOH |
|00002d00| 4e 4f 21 21 20 46 6f 75 | 6e 64 20 61 20 64 75 70 |NO!! Fou|nd a dup|
|00002d10| 6c 69 63 61 74 65 20 61 | 75 74 68 6f 72 20 43 68 |licate a|uthor Ch|
|00002d20| 75 6e 6b 21 21 22 29 3b | 0d 0d 09 09 09 09 69 66 |unk!!");|......if|
|00002d30| 20 28 20 21 28 63 68 75 | 6e 6b 46 6c 61 67 73 20 | ( !(chu|nkFlags |
|00002d40| 26 20 6b 41 75 74 68 6f | 72 29 20 29 20 7b 09 09 |& kAutho|r) ) {..|
|00002d50| 09 09 09 09 09 09 09 09 | 09 09 09 09 09 2f 2f 20 |........|.....// |
|00002d60| 20 73 65 65 20 69 66 20 | 74 68 69 73 20 63 68 75 | see if |this chu|
|00002d70| 6e 6b 20 61 6c 72 65 61 | 64 79 20 65 78 69 73 74 |nk alrea|dy exist|
|00002d80| 73 0d 09 09 09 09 09 63 | 68 75 6e 6b 46 6c 61 67 |s......c|hunkFlag|
|00002d90| 73 20 7c 3d 20 6b 41 75 | 74 68 6f 72 3b 09 09 09 |s |= kAu|thor;...|
|00002da0| 09 09 09 09 09 09 09 09 | 09 09 09 09 09 2f 2f 09 |........|.....//.|
|00002db0| 09 6f 74 68 65 72 77 69 | 73 65 20 6d 61 72 6b 20 |.otherwi|se mark |
|00002dc0| 69 74 20 66 6f 75 6e 64 | 0d 09 09 09 09 09 66 69 |it found|......fi|
|00002dd0| 6c 65 50 6f 73 69 74 69 | 6f 6e 20 2b 3d 20 74 65 |lePositi|on += te|
|00002de0| 6d 70 6c 61 74 65 2d 3e | 67 65 6e 65 72 69 63 2e |mplate->|generic.|
|00002df0| 63 6b 53 69 7a 65 20 2b | 20 6b 43 68 75 6e 6b 48 |ckSize +| kChunkH|
|00002e00| 65 61 64 65 72 53 69 7a | 65 3b 09 09 09 09 09 09 |eaderSiz|e;......|
|00002e10| 2f 2f 09 09 63 61 6c 63 | 75 6c 61 74 65 20 6e 65 |//..calc|ulate ne|
|00002e20| 78 74 20 63 68 75 6e 6b | 27 73 20 70 6f 73 69 74 |xt chunk|'s posit|
|00002e30| 69 6f 6e 0d 09 09 09 09 | 09 65 72 72 20 3d 20 6e |ion.....|.err = n|
|00002e40| 6f 45 72 72 3b 0d 09 09 | 09 09 7d 0d 09 09 09 09 |oErr;...|..}.....|
|00002e50| 62 72 65 61 6b 3b 0d 0d | 0d 09 09 09 63 61 73 65 |break;..|....case|
|00002e60| 20 43 6f 70 79 72 69 67 | 68 74 49 44 3a 0d 09 09 | Copyrig|htID:...|
|00002e70| 09 09 44 65 62 75 67 4d | 65 73 73 61 67 65 20 28 |..DebugM|essage (|
|00002e80| 22 5c 70 66 6f 75 6e 64 | 20 61 20 63 6f 70 79 72 |"\pfound| a copyr|
|00002e90| 69 67 68 74 20 63 68 75 | 6e 6b 22 29 3b 0d 09 09 |ight chu|nk");...|
|00002ea0| 09 09 41 73 73 65 72 74 | 20 28 28 63 68 75 6e 6b |..Assert| ((chunk|
|00002eb0| 46 6c 61 67 73 20 26 20 | 6b 43 6f 70 79 72 69 67 |Flags & |kCopyrig|
|00002ec0| 68 74 29 2c 20 22 5c 70 | 4f 48 20 4e 4f 21 21 20 |ht), "\p|OH NO!! |
|00002ed0| 46 6f 75 6e 64 20 61 20 | 64 75 70 6c 69 63 61 74 |Found a |duplicat|
|00002ee0| 65 20 63 6f 70 79 72 69 | 67 68 74 20 43 68 75 6e |e copyri|ght Chun|
|00002ef0| 6b 21 21 22 29 3b 0d 0d | 09 09 09 09 69 66 20 28 |k!!");..|....if (|
|00002f00| 20 21 28 63 68 75 6e 6b | 46 6c 61 67 73 20 26 20 | !(chunk|Flags & |
|00002f10| 6b 43 6f 70 79 72 69 67 | 68 74 29 20 29 20 7b 09 |kCopyrig|ht) ) {.|
|00002f20| 09 09 09 09 09 09 09 09 | 09 09 09 09 09 09 2f 2f |........|......//|
|00002f30| 20 20 73 65 65 20 69 66 | 20 74 68 69 73 20 63 68 | see if| this ch|
|00002f40| 75 6e 6b 20 61 6c 72 65 | 61 64 79 20 65 78 69 73 |unk alre|ady exis|
|00002f50| 74 73 0d 09 09 09 09 09 | 63 68 75 6e 6b 46 6c 61 |ts......|chunkFla|
|00002f60| 67 73 20 7c 3d 20 6b 43 | 6f 70 79 72 69 67 68 74 |gs |= kC|opyright|
|00002f70| 3b 09 09 09 09 09 09 09 | 09 09 09 09 09 09 09 09 |;.......|........|
|00002f80| 2f 2f 09 09 6f 74 68 65 | 72 77 69 73 65 20 6d 61 |//..othe|rwise ma|
|00002f90| 72 6b 20 69 74 20 66 6f | 75 6e 64 0d 09 09 09 09 |rk it fo|und.....|
|00002fa0| 09 66 69 6c 65 50 6f 73 | 69 74 69 6f 6e 20 2b 3d |.filePos|ition +=|
|00002fb0| 20 74 65 6d 70 6c 61 74 | 65 2d 3e 67 65 6e 65 72 | templat|e->gener|
|00002fc0| 69 63 2e 63 6b 53 69 7a | 65 20 2b 20 6b 43 68 75 |ic.ckSiz|e + kChu|
|00002fd0| 6e 6b 48 65 61 64 65 72 | 53 69 7a 65 3b 09 09 09 |nkHeader|Size;...|
|00002fe0| 09 09 09 2f 2f 09 09 63 | 61 6c 63 75 6c 61 74 65 |...//..c|alculate|
|00002ff0| 20 6e 65 78 74 20 63 68 | 75 6e 6b 27 73 20 70 6f | next ch|unk's po|
|00003000| 73 69 74 69 6f 6e 0d 09 | 09 09 09 09 65 72 72 20 |sition..|....err |
|00003010| 3d 20 6e 6f 45 72 72 3b | 0d 09 09 09 09 7d 0d 09 |= noErr;|.....}..|
|00003020| 09 09 09 62 72 65 61 6b | 3b 0d 0d 0d 09 09 09 63 |...break|;......c|
|00003030| 61 73 65 20 41 6e 6e 6f | 74 61 74 69 6f 6e 49 44 |ase Anno|tationID|
|00003040| 3a 0d 09 09 09 09 44 65 | 62 75 67 4d 65 73 73 61 |:.....De|bugMessa|
|00003050| 67 65 20 28 22 5c 70 66 | 6f 75 6e 64 20 61 6e 20 |ge ("\pf|ound an |
|00003060| 75 6e 69 6e 74 65 72 65 | 73 74 69 6e 67 20 63 68 |unintere|sting ch|
|00003070| 75 6e 6b 22 29 3b 0d 09 | 09 09 09 41 73 73 65 72 |unk");..|...Asser|
|00003080| 74 20 28 28 63 68 75 6e | 6b 46 6c 61 67 73 20 26 |t ((chun|kFlags &|
|00003090| 20 6b 41 6e 6e 6f 74 61 | 74 69 6f 6e 29 2c 20 22 | kAnnota|tion), "|
|000030a0| 5c 70 4f 48 20 4e 4f 21 | 21 20 46 6f 75 6e 64 20 |\pOH NO!|! Found |
|000030b0| 61 20 64 75 70 6c 69 63 | 61 74 65 20 61 6e 6e 6f |a duplic|ate anno|
|000030c0| 74 61 74 69 6f 6e 20 43 | 68 75 6e 6b 21 21 22 29 |tation C|hunk!!")|
|000030d0| 3b 0d 0d 09 09 09 09 69 | 66 20 28 20 21 28 63 68 |;......i|f ( !(ch|
|000030e0| 75 6e 6b 46 6c 61 67 73 | 20 26 20 6b 41 6e 6e 6f |unkFlags| & kAnno|
|000030f0| 74 61 74 69 6f 6e 29 20 | 29 20 7b 09 09 09 09 09 |tation) |) {.....|
|00003100| 09 09 09 09 09 09 09 09 | 09 2f 2f 20 20 73 65 65 |........|.// see|
|00003110| 20 69 66 20 74 68 69 73 | 20 63 68 75 6e 6b 20 61 | if this| chunk a|
|00003120| 6c 72 65 61 64 79 20 65 | 78 69 73 74 73 0d 09 09 |lready e|xists...|
|00003130| 09 09 09 63 68 75 6e 6b | 46 6c 61 67 73 20 7c 3d |...chunk|Flags |=|
|00003140| 20 6b 41 6e 6e 6f 74 61 | 74 69 6f 6e 3b 09 09 09 | kAnnota|tion;...|
|00003150| 09 09 09 09 09 09 09 09 | 09 09 09 09 2f 2f 09 09 |........|....//..|
|00003160| 6f 74 68 65 72 77 69 73 | 65 20 6d 61 72 6b 20 69 |otherwis|e mark i|
|00003170| 74 20 66 6f 75 6e 64 0d | 09 09 09 09 09 66 69 6c |t found.|.....fil|
|00003180| 65 50 6f 73 69 74 69 6f | 6e 20 2b 3d 20 74 65 6d |ePositio|n += tem|
|00003190| 70 6c 61 74 65 2d 3e 67 | 65 6e 65 72 69 63 2e 63 |plate->g|eneric.c|
|000031a0| 6b 53 69 7a 65 20 2b 20 | 6b 43 68 75 6e 6b 48 65 |kSize + |kChunkHe|
|000031b0| 61 64 65 72 53 69 7a 65 | 3b 09 09 09 09 09 09 2f |aderSize|;....../|
|000031c0| 2f 09 09 63 61 6c 63 75 | 6c 61 74 65 20 6e 65 78 |/..calcu|late nex|
|000031d0| 74 20 63 68 75 6e 6b 27 | 73 20 70 6f 73 69 74 69 |t chunk'|s positi|
|000031e0| 6f 6e 0d 09 09 09 09 09 | 65 72 72 20 3d 20 6e 6f |on......|err = no|
|000031f0| 45 72 72 3b 0d 09 09 09 | 09 7d 0d 09 09 09 09 62 |Err;....|.}.....b|
|00003200| 72 65 61 6b 3b 0d 0d 0d | 09 09 09 64 65 66 61 75 |reak;...|...defau|
|00003210| 6c 74 20 3a 09 09 09 09 | 09 09 09 09 09 09 09 09 |lt :....|........|
|00003220| 09 09 09 09 09 09 09 09 | 09 2f 2f 20 55 6e 72 65 |........|.// Unre|
|00003230| 63 6f 67 6e 69 7a 65 64 | 3f 3f 20 63 72 6f 61 6b |cognized|?? croak|
|00003240| 2e 0d 09 09 09 09 41 73 | 73 65 72 74 20 28 74 72 |......As|sert (tr|
|00003250| 75 65 2c 20 22 5c 70 72 | 61 6e 20 69 6e 74 6f 20 |ue, "\pr|an into |
|00003260| 61 6e 20 75 6e 64 65 66 | 69 6e 65 64 20 63 68 75 |an undef|ined chu|
|00003270| 6e 6b 21 21 22 29 3b 0d | 0d 09 09 09 09 2f 2f 09 |nk!!");.|.....//.|
|00003280| 49 66 20 77 65 20 68 69 | 74 20 61 6e 20 75 6e 72 |If we hi|t an unr|
|00003290| 65 63 6f 67 6e 69 7a 65 | 64 20 63 68 75 6e 6b 2c |ecognize|d chunk,|
|000032a0| 20 63 6c 65 61 72 20 63 | 68 75 6e 6b 46 6c 61 67 | clear c|hunkFlag|
|000032b0| 73 20 74 6f 20 64 72 6f | 70 20 6f 75 74 20 6f 66 |s to dro|p out of|
|000032c0| 20 74 68 65 20 6c 6f 6f | 70 0d 09 09 09 09 2f 2f | the loo|p.....//|
|000032d0| 20 20 77 69 74 68 20 74 | 68 65 20 61 73 73 75 6d | with t|he assum|
|000032e0| 65 64 20 65 72 72 6f 72 | 20 63 6f 64 65 2e 0d 09 |ed error| code...|
|000032f0| 09 09 09 63 68 75 6e 6b | 46 6c 61 67 73 20 3d 20 |...chunk|Flags = |
|00003300| 30 3b 0d 09 09 09 09 62 | 72 65 61 6b 3b 0d 09 09 |0;.....b|reak;...|
|00003310| 7d 0d 0d 09 2f 2f 09 57 | 65 27 72 65 20 6f 6e 6c |}...//.W|e're onl|
|00003320| 79 20 64 6f 6e 65 20 77 | 68 65 6e 20 74 68 65 20 |y done w|hen the |
|00003330| 74 68 65 20 46 4f 52 4d | 2c 20 46 6f 72 6d 61 74 |the FORM|, Format|
|00003340| 56 65 72 73 69 6f 6e 2c | 20 43 6f 6d 6d 6f 6e 20 |Version,| Common |
|00003350| 61 6e 64 20 53 6f 75 6e | 64 20 44 61 74 61 20 63 |and Soun|d Data c|
|00003360| 68 75 6e 6b 73 2e 20 20 | 54 68 69 73 20 69 73 20 |hunks. |This is |
|00003370| 6f 6e 6c 79 0d 09 2f 2f | 09 74 72 75 65 20 6f 66 |only..//|.true of|
|00003380| 20 74 68 69 73 20 69 6e | 63 61 72 6e 61 74 69 6f | this in|carnatio|
|00003390| 6e 20 2d 20 79 6f 75 72 | 20 6e 65 65 64 73 20 6d |n - your| needs m|
|000033a0| 61 79 20 76 61 72 79 2c | 20 73 6f 20 79 6f 75 27 |ay vary,| so you'|
|000033b0| 6c 6c 20 68 61 76 65 20 | 74 6f 20 6d 6f 64 69 66 |ll have |to modif|
|000033c0| 79 20 74 68 65 20 66 6f | 6c 6c 6f 77 69 6e 67 20 |y the fo|llowing |
|000033d0| 73 74 61 74 65 6d 65 6e | 74 0d 09 2f 2f 09 61 63 |statemen|t..//.ac|
|000033e0| 63 6f 72 64 69 6e 67 6c | 79 2e 2e 2e 0d 09 2f 2f |cordingl|y.....//|
|000033f0| 20 20 49 20 6b 6e 6f 77 | 2c 20 74 68 69 73 20 63 | I know|, this c|
|00003400| 6c 61 75 73 65 20 69 73 | 20 61 20 70 61 69 6e 20 |lause is| a pain |
|00003410| 69 6e 20 74 68 65 20 61 | 73 73 3a 20 20 77 68 61 |in the a|ss: wha|
|00003420| 74 20 69 74 20 72 65 61 | 6c 6c 79 20 73 61 79 73 |t it rea|lly says|
|00003430| 20 69 73 20 74 68 69 73 | 3a 0d 09 2f 2f 09 09 41 | is this|:..//..A|
|00003440| 73 20 6c 6f 6e 67 20 61 | 73 20 77 65 20 68 61 76 |s long a|s we hav|
|00003450| 65 20 61 20 46 4f 52 4d | 20 43 68 75 6e 6b 20 61 |e a FORM| Chunk a|
|00003460| 6e 64 20 77 65 20 64 6f | 6e 27 74 20 68 61 76 65 |nd we do|n't have|
|00003470| 20 61 6c 6c 20 6f 66 20 | 74 68 65 20 7b 46 6f 72 | all of |the {For|
|00003480| 6d 61 74 76 65 72 73 69 | 6f 6e 2c 20 43 6f 6d 6d |matversi|on, Comm|
|00003490| 6f 6e 2c 20 53 6f 75 6e | 64 44 61 74 61 7d 20 63 |on, Soun|dData} c|
|000034a0| 68 75 6e 6b 73 0d 09 2f | 2f 09 09 6b 65 65 70 20 |hunks../|/..keep |
|000034b0| 67 6f 69 6e 67 2e 2e 2e | 20 41 4e 44 20 77 65 20 |going...| AND we |
|000034c0| 68 61 76 65 6e 27 74 20 | 67 6f 74 74 65 6e 20 61 |haven't |gotten a|
|000034d0| 6e 20 65 72 72 6f 72 20 | 66 72 6f 6d 20 74 68 65 |n error |from the|
|000034e0| 20 66 69 6c 65 20 73 79 | 73 74 65 6d 2e 0d 09 7d | file sy|stem...}|
|000034f0| 20 77 68 69 6c 65 20 28 | 09 28 63 68 75 6e 6b 46 | while (|.(chunkF|
|00003500| 6c 61 67 73 20 26 20 6b | 46 4f 52 4d 29 0d 09 09 |lags & k|FORM)...|
|00003510| 09 09 26 26 20 28 21 28 | 63 68 75 6e 6b 46 6c 61 |..&& (!(|chunkFla|
|00003520| 67 73 20 26 20 6b 43 6f | 6d 6d 6f 6e 29 20 7c 7c |gs & kCo|mmon) |||
|00003530| 20 21 28 63 68 75 6e 6b | 46 6c 61 67 73 20 26 20 | !(chunk|Flags & |
|00003540| 6b 53 6f 75 6e 64 44 61 | 74 61 29 29 0d 09 09 09 |kSoundDa|ta))....|
|00003550| 09 26 26 20 28 65 72 72 | 20 3d 3d 20 6e 6f 45 72 |.&& (err| == noEr|
|00003560| 72 29 20 29 3b 0d 0d 09 | 2f 2f 09 49 66 20 77 65 |r) );...|//.If we|
|00003570| 20 63 6f 6d 70 6c 65 74 | 65 64 20 6e 6f 72 6d 61 | complet|ed norma|
|00003580| 6c 6c 79 2c 20 50 6f 73 | 69 74 69 6f 6e 20 74 68 |lly, Pos|ition th|
|00003590| 65 20 6d 61 72 6b 20 61 | 74 20 74 68 65 20 62 65 |e mark a|t the be|
|000035a0| 67 69 6e 6e 69 6e 67 20 | 6f 66 20 74 68 65 20 73 |ginning |of the s|
|000035b0| 6f 75 6e 64 20 64 61 74 | 61 0d 09 69 66 20 28 63 |ound dat|a..if (c|
|000035c0| 68 75 6e 6b 46 6c 61 67 | 73 20 26 26 20 28 65 72 |hunkFlag|s && (er|
|000035d0| 72 20 3d 3d 20 6e 6f 45 | 72 72 29 20 29 20 7b 0d |r == noE|rr) ) {.|
|000035e0| 09 09 65 72 72 20 3d 20 | 53 65 74 46 50 6f 73 20 |..err = |SetFPos |
|000035f0| 28 66 72 65 66 4e 75 6d | 2c 20 66 73 46 72 6f 6d |(frefNum|, fsFrom|
|00003600| 53 74 61 72 74 2c 20 64 | 61 74 61 53 74 61 72 74 |Start, d|ataStart|
|00003610| 29 3b 09 09 09 09 09 09 | 09 09 09 09 09 09 2f 2f |);......|......//|
|00003620| 20 6d 6f 76 65 20 6d 61 | 72 6b 20 74 6f 20 64 61 | move ma|rk to da|
|00003630| 74 61 20 73 74 61 72 74 | 0d 09 09 41 73 73 65 72 |ta start|...Asser|
|00003640| 74 20 28 28 65 72 72 20 | 21 3d 20 6e 6f 45 72 72 |t ((err |!= noErr|
|00003650| 29 2c 20 22 5c 70 53 65 | 74 46 50 6f 73 20 66 61 |), "\pSe|tFPos fa|
|00003660| 69 6c 65 64 22 29 3b 0d | 09 7d 0d 09 69 66 20 28 |iled");.|.}..if (|
|00003670| 65 72 72 20 21 3d 20 6e | 6f 45 72 72 29 0d 09 09 |err != n|oErr)...|
|00003680| 64 61 74 61 53 69 7a 65 | 20 3d 20 30 3b 09 09 09 |dataSize| = 0;...|
|00003690| 09 09 09 09 09 2f 2f 20 | 73 69 67 6e 61 6c 20 61 |.....// |signal a|
|000036a0| 20 66 61 69 6c 75 72 65 | 0d 09 72 65 74 75 72 6e | failure|..return|
|000036b0| 20 28 64 61 74 61 53 69 | 7a 65 29 3b 0d 7d 0d 0d | (dataSi|ze);.}..|
|000036c0| 2f 2f 0d 2f 2f 09 09 09 | 52 65 63 6f 72 64 73 20 |//.//...|Records |
|000036d0| 66 72 6f 6d 20 74 68 65 | 20 63 75 72 72 65 6e 74 |from the| current|
|000036e0| 6c 79 20 73 65 6c 65 63 | 74 65 64 20 73 6f 75 6e |ly selec|ted soun|
|000036f0| 64 20 69 6e 70 75 74 20 | 64 65 76 69 63 65 20 69 |d input |device i|
|00003700| 6e 74 6f 20 61 20 66 69 | 6c 65 2e 0d 2f 2f 09 09 |nto a fi|le..//..|
|00003710| 09 54 68 65 20 65 72 72 | 6f 72 20 79 6f 75 20 67 |.The err|or you g|
|00003720| 65 74 20 62 61 63 6b 20 | 63 61 6e 20 62 65 20 66 |et back |can be f|
|00003730| 72 6f 6d 20 73 74 61 6e | 64 61 72 64 66 69 6c 65 |rom stan|dardfile|
|00003740| 2c 20 66 69 6c 65 20 6d | 61 6e 61 67 65 72 20 6f |, file m|anager o|
|00003750| 72 20 74 68 65 20 73 6f | 75 6e 64 20 6d 61 6e 61 |r the so|und mana|
|00003760| 67 65 72 0d 2f 2f 0d 4f | 53 45 72 72 20 52 65 63 |ger.//.O|SErr Rec|
|00003770| 6f 72 64 41 49 46 46 46 | 69 6c 65 20 28 4f 53 54 |ordAIFFF|ile (OST|
|00003780| 79 70 65 20 63 72 65 61 | 74 6f 72 29 0d 7b 0d 09 |ype crea|tor).{..|
|00003790| 73 68 6f 72 74 20 09 09 | 09 09 09 66 52 65 66 4e |short ..|...fRefN|
|000037a0| 75 6d 3b 0d 09 4f 53 45 | 72 72 09 09 09 09 09 65 |um;..OSE|rr.....e|
|000037b0| 72 72 3b 0d 09 50 6f 69 | 6e 74 09 09 09 09 09 68 |rr;..Poi|nt.....h|
|000037c0| 65 72 65 3b 0d 09 53 74 | 61 6e 64 61 72 64 46 69 |ere;..St|andardFi|
|000037d0| 6c 65 52 65 70 6c 79 09 | 09 73 52 65 70 6c 79 3b |leReply.|.sReply;|
|000037e0| 0d 0d 09 53 74 61 6e 64 | 61 72 64 50 75 74 46 69 |...Stand|ardPutFi|
|000037f0| 6c 65 20 28 22 5c 70 52 | 65 63 6f 72 64 20 74 6f |le ("\pR|ecord to|
|00003800| 3a 22 2c 20 22 5c 70 4e | 65 77 20 41 49 46 46 20 |:", "\pN|ew AIFF |
|00003810| 46 69 6c 65 22 2c 20 26 | 73 52 65 70 6c 79 29 3b |File", &|sReply);|
|00003820| 0d 09 41 73 73 65 72 74 | 20 28 28 21 73 52 65 70 |..Assert| ((!sRep|
|00003830| 6c 79 2e 73 66 47 6f 6f | 64 29 2c 20 22 5c 70 46 |ly.sfGoo|d), "\pF|
|00003840| 61 69 6c 65 64 20 69 6e | 20 73 74 61 6e 64 61 72 |ailed in| standar|
|00003850| 64 66 69 6c 65 22 29 3b | 0d 0d 09 69 66 20 28 73 |dfile");|...if (s|
|00003860| 52 65 70 6c 79 2e 73 66 | 47 6f 6f 64 29 20 7b 09 |Reply.sf|Good) {.|
|00003870| 09 09 09 09 09 09 09 09 | 09 09 09 09 2f 2f 20 56 |........|....// V|
|00003880| 61 6c 69 64 20 66 69 6c | 65 20 73 65 6c 65 63 74 |alid fil|e select|
|00003890| 65 64 3f 0d 09 0d 09 09 | 2f 2f 09 53 74 61 6e 64 |ed?.....|//.Stand|
|000038a0| 61 72 64 20 66 69 6c 65 | 20 73 75 72 76 69 76 65 |ard file| survive|
|000038b0| 64 20 74 68 65 20 75 73 | 65 72 21 21 20 44 65 63 |d the us|er!! Dec|
|000038c0| 69 64 65 20 69 66 20 74 | 68 65 20 66 69 6c 65 20 |ide if t|he file |
|000038d0| 65 78 69 73 74 73 20 6f | 72 20 6e 65 65 64 73 20 |exists o|r needs |
|000038e0| 74 6f 20 62 65 20 63 72 | 65 61 74 65 64 0d 09 09 |to be cr|eated...|
|000038f0| 69 66 20 28 73 52 65 70 | 6c 79 2e 73 66 52 65 70 |if (sRep|ly.sfRep|
|00003900| 6c 61 63 69 6e 67 29 20 | 7b 0d 0d 09 09 09 65 72 |lacing) |{.....er|
|00003910| 72 20 3d 20 46 53 70 44 | 65 6c 65 74 65 20 28 26 |r = FSpD|elete (&|
|00003920| 73 52 65 70 6c 79 2e 73 | 66 46 69 6c 65 29 3b 0d |sReply.s|fFile);.|
|00003930| 09 09 09 41 73 73 65 72 | 74 20 28 65 72 72 2c 20 |...Asser|t (err, |
|00003940| 22 5c 70 43 6f 75 6c 64 | 6e 27 74 20 64 65 6c 65 |"\pCould|n't dele|
|00003950| 74 65 20 65 78 69 73 74 | 69 6e 67 20 66 69 6c 65 |te exist|ing file|
|00003960| 22 29 3b 0d 09 09 7d 0d | 0d 09 09 2f 2f 09 4e 6f |");...}.|...//.No|
|00003970| 77 20 63 72 65 61 74 65 | 20 61 20 6e 65 77 20 66 |w create| a new f|
|00003980| 69 6c 65 20 61 6e 64 20 | 74 68 65 6e 20 6f 70 65 |ile and |then ope|
|00003990| 6e 20 69 74 2e 2e 2e 0d | 09 09 65 72 72 20 3d 20 |n it....|..err = |
|000039a0| 46 53 70 43 72 65 61 74 | 65 20 28 26 73 52 65 70 |FSpCreat|e (&sRep|
|000039b0| 6c 79 2e 73 66 46 69 6c | 65 2c 20 63 72 65 61 74 |ly.sfFil|e, creat|
|000039c0| 6f 72 2c 20 27 41 49 46 | 46 27 2c 69 75 53 79 73 |or, 'AIF|F',iuSys|
|000039d0| 74 65 6d 53 63 72 69 70 | 74 29 3b 0d 09 09 41 73 |temScrip|t);...As|
|000039e0| 73 65 72 74 20 28 65 72 | 72 2c 20 22 5c 70 43 6f |sert (er|r, "\pCo|
|000039f0| 75 6c 64 6e 27 74 20 63 | 72 65 61 74 65 20 66 69 |uldn't c|reate fi|
|00003a00| 6c 65 22 29 3b 0d 09 09 | 69 66 20 28 65 72 72 20 |le");...|if (err |
|00003a10| 3d 3d 20 6e 6f 45 72 72 | 29 20 7b 0d 09 09 09 65 |== noErr|) {....e|
|00003a20| 72 72 20 3d 20 46 53 70 | 4f 70 65 6e 44 46 20 28 |rr = FSp|OpenDF (|
|00003a30| 26 73 52 65 70 6c 79 2e | 73 66 46 69 6c 65 2c 20 |&sReply.|sfFile, |
|00003a40| 66 73 52 64 57 72 50 65 | 72 6d 2c 20 26 66 52 65 |fsRdWrPe|rm, &fRe|
|00003a50| 66 4e 75 6d 29 3b 0d 09 | 09 09 41 73 73 65 72 74 |fNum);..|..Assert|
|00003a60| 20 28 65 72 72 2c 20 22 | 5c 70 43 6f 75 6c 64 6e | (err, "|\pCouldn|
|00003a70| 27 74 20 6f 70 65 6e 20 | 66 69 6c 65 22 29 3b 0d |'t open |file");.|
|00003a80| 09 09 7d 0d 09 7d 20 65 | 6c 73 65 0d 09 09 65 72 |..}..} e|lse...er|
|00003a90| 72 20 3d 20 75 73 65 72 | 43 61 6e 63 65 6c 65 64 |r = user|Canceled|
|00003aa0| 45 72 72 3b 09 09 09 09 | 09 09 09 09 09 09 09 09 |Err;....|........|
|00003ab0| 09 09 09 09 09 09 09 09 | 09 2f 2f 20 20 20 4e 6f |........|.// No|
|00003ac0| 21 20 72 65 74 75 72 6e | 20 65 72 72 6f 72 2e 2e |! return| error..|
|00003ad0| 2e 0d 0d 09 69 66 20 28 | 65 72 72 20 3d 3d 20 6e |....if (|err == n|
|00003ae0| 6f 45 72 72 29 20 7b 0d | 09 0d 09 09 2f 2f 09 72 |oErr) {.|....//.r|
|00003af0| 65 63 6f 72 64 20 74 6f | 20 74 68 65 20 66 69 6c |ecord to| the fil|
|00003b00| 65 20 75 73 69 6e 67 20 | 74 68 65 20 68 69 67 68 |e using |the high|
|00003b10| 65 73 74 20 6c 65 76 65 | 6c 20 72 6f 75 74 69 6e |est leve|l routin|
|00003b20| 65 73 20 61 76 61 69 6c | 61 62 6c 65 2e 20 20 54 |es avail|able. T|
|00003b30| 68 69 73 20 67 69 76 65 | 73 0d 09 09 2f 2f 09 75 |his give|s...//.u|
|00003b40| 73 20 61 20 72 65 61 64 | 79 20 6d 61 64 65 20 75 |s a read|y made u|
|00003b50| 73 65 72 20 69 6e 74 65 | 72 66 61 63 65 2e 2e 2e |ser inte|rface...|
|00003b60| 2e 0d 09 09 68 65 72 65 | 2e 68 20 3d 20 33 30 3b |....here|.h = 30;|
|00003b70| 0d 09 09 68 65 72 65 2e | 76 20 3d 20 33 30 3b 0d |...here.|v = 30;.|
|00003b80| 09 09 65 72 72 20 3d 20 | 53 6e 64 52 65 63 6f 72 |..err = |SndRecor|
|00003b90| 64 54 6f 46 69 6c 65 28 | 6e 69 6c 2c 20 68 65 72 |dToFile(|nil, her|
|00003ba0| 65 2c 20 73 69 42 65 73 | 74 51 75 61 6c 69 74 79 |e, siBes|tQuality|
|00003bb0| 2c 20 66 52 65 66 4e 75 | 6d 29 3b 0d 09 09 41 73 |, fRefNu|m);...As|
|00003bc0| 73 65 72 74 20 28 65 72 | 72 2c 20 22 5c 70 42 6f |sert (er|r, "\pBo|
|00003bd0| 6d 62 65 64 20 6f 75 74 | 20 72 65 63 6f 72 64 69 |mbed out| recordi|
|00003be0| 6e 67 2e 2e 2e 22 29 3b | 0d 09 0d 09 09 2f 2f 09 |ng...");|.....//.|
|00003bf0| 4e 6f 77 20 74 68 61 74 | 20 77 65 27 72 65 20 64 |Now that| we're d|
|00003c00| 6f 6e 65 20 28 66 6f 72 | 20 62 65 74 74 65 72 20 |one (for| better |
|00003c10| 6f 72 20 66 6f 72 20 77 | 6f 72 73 65 29 20 63 6c |or for w|orse) cl|
|00003c20| 6f 73 65 20 74 68 65 20 | 66 69 6c 65 2e 2e 2e 0d |ose the |file....|
|00003c30| 09 09 46 53 43 6c 6f 73 | 65 20 28 66 52 65 66 4e |..FSClos|e (fRefN|
|00003c40| 75 6d 29 3b 0d 09 7d 0d | 09 72 65 74 75 72 6e 20 |um);..}.|.return |
|00003c50| 28 65 72 72 29 3b 0d 7d | 0d 00 00 00 00 00 00 00 |(err);.}|........|
|00003c60| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003c70| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003c80| 00 00 01 00 00 00 02 22 | 00 00 01 22 00 00 00 56 |......."|..."...V|
|00003c90| f8 26 13 1d 52 4a 00 50 | 8f 01 67 52 26 01 30 02 |.&..RJ.P|..gR&.0.|
|00003ca0| ef 26 01 30 32 76 36 12 | 42 10 48 78 01 0b ea 57 |.&.02v6.|B.Hx...W|
|00003cb0| 0d 41 49 46 46 47 6f 6f | 64 69 65 73 2e 63 02 00 |.AIFFGoo|dies.c..|
|00003cc0| 00 00 54 45 58 54 4d 50 | 53 20 01 00 ff ff ff ff |..TEXTMP|S ......|
|00003cd0| 00 00 54 45 58 54 4d 50 | 53 20 01 00 ff ff ff ff |..TEXTMP|S ......|
|00003ce0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003cf0| 00 00 a4 fa 79 3f 00 00 | 3b d9 00 00 02 78 01 ff |....y?..|;....x..|
|00003d00| 8a 8b c1 50 04 09 82 38 | 00 7c ff 1e 38 11 0a 5e |...P...8|.|..8..^|
|00003d10| 01 11 c6 3e 01 1a 07 98 | 99 02 53 54 52 20 5d 02 |...>....|..STR ].|
|00003d20| bf 84 a9 a0 af 03 3f 04 | a9 98 11 c5 3e 96 67 03 |......?.|....>.g.|
|00003d30| 67 4a 4a 93 67 46 51 c8 | 57 f5 50 01 08 1a 57 01 |gJJ.gFQ.|W.P...W.|
|00003d40| ff 74 50 14 12 02 4a 40 | 4f ef 00 0c 01 66 2a 76 |.tP...J@|O....f*v|
|00003d50| f5 c0 11 ff 0c 3d 01 ff | 2a 28 01 ff 10 d4 01 ff |.....=..|*(......|
|00003d60| 14 91 57 01 fe fa 8b 01 | 1f 01 50 02 02 7a 54 8f |..W.....|..P..zT.|
|00003d70| 73 02 18 f0 fe e2 2b 11 | fe 84 32 26 02 2f ea 2c |s.....+.|..2&./.,|
|00003d80| 00 00 00 78 00 03 00 00 | 00 48 00 48 00 00 00 00 |...x....|.H.H....|
|00003d90| 02 e0 03 ce ff d8 ff d7 | 03 08 03 f7 03 45 05 28 |........|.....E.(|
|00003da0| 03 fc 00 02 00 00 00 48 | 00 48 00 00 00 00 02 e0 |.......H|.H......|
|00003db0| 03 ce 00 01 00 00 00 4b | 00 00 00 01 00 01 01 01 |.......K|........|
|00003dc0| 00 00 00 01 27 0f 00 01 | 00 01 00 00 00 00 00 00 |....'...|........|
|00003dd0| 00 00 00 00 00 00 00 02 | 00 19 01 90 00 00 00 00 |........|........|
|00003de0| 00 40 00 00 00 00 00 00 | 00 00 00 01 00 00 00 00 |.@......|........|
|00003df0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 48 |........|.......H|
|00003e00| 00 09 4d 6f 6e 61 63 6f | 00 6f 75 74 69 6e 65 73 |..Monaco|.outines|
|00003e10| 20 74 68 61 74 20 70 65 | 72 74 69 61 6e 20 74 6f | that pe|rtian to|
|00003e20| 20 6f 00 06 00 04 00 b4 | 00 0c 03 63 04 3d 00 b4 | o......|...c.=..|
|00003e30| 00 0c 03 63 04 3d a6 6e | 11 61 00 00 14 3b 00 00 |...c.=.n|.a...;..|
|00003e40| 14 3b 00 00 14 3a 01 00 | 00 00 00 34 00 02 00 00 |.;...:..|...4....|
|00003e50| 08 63 00 00 08 74 11 47 | 65 74 41 49 46 46 48 65 |.c...t.G|etAIFFHe|
|00003e60| 61 64 65 72 49 6e 66 6f | 00 00 36 ed 00 00 36 fb |aderInfo|..6...6.|
|00003e70| 0f 52 65 63 6f 72 64 41 | 49 46 46 46 69 6c 65 00 |.RecordA|IFFFile.|
|00003e80| 00 00 00 1e 00 b4 00 0c | 03 63 04 3d 00 b4 00 0c |........|.c.=....|
|00003e90| 03 63 04 3d 00 00 14 3a | 00 00 00 00 00 00 00 00 |.c.=...:|........|
|00003ea0| 00 00 00 00 01 00 00 00 | 02 22 00 00 01 22 00 00 |........|."..."..|
|00003eb0| 00 56 00 82 88 f8 0a a8 | 00 00 00 1c 00 56 00 00 |.V......|.....V..|
|00003ec0| 4d 50 53 52 00 03 00 0a | 03 ee ff ff 00 00 00 00 |MPSR....|........|
|00003ed0| 00 00 00 00 03 ed ff ff | 00 00 00 7c 00 00 00 00 |........|...|....|
|00003ee0| 03 ef ff ff 00 00 00 c8 | 00 00 00 00 03 f0 ff ff |........|........|
|00003ef0| 00 00 01 00 00 88 b1 38 | 00 00 00 00 00 00 00 00 |.......8|........|
+--------+-------------------------+-------------------------+--------+--------+